用户登录时的Android通知
我正在开发一个安卓应用程序,我正在使用安卓工作室来完成它。所以我制作了这个应用程序,基本上管理员可以向用户发送“请求”。您可以以管理员或用户身份登录该应用程序,我是这样做的:用户登录时的Android通知,android,Android,我正在开发一个安卓应用程序,我正在使用安卓工作室来完成它。所以我制作了这个应用程序,基本上管理员可以向用户发送“请求”。您可以以管理员或用户身份登录该应用程序,我是这样做的: public class MainActivity extends Activity { public static Button b_connexion ; public static EditText et_identifiant ; public static EditText et_pas
public class MainActivity extends Activity {
public static Button b_connexion ;
public static EditText et_identifiant ;
public static EditText et_password ;
public static String mdpInterprete;
public static String mdpAdmin;
public static InterpretesDAO unInterpreteDAO;
public static AdminDAO unAdminDAO;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
unInterpreteDAO = new InterpretesDAO(this);
unAdminDAO = new AdminDAO(this);
b_connexion = (Button) findViewById(R.id.b_connexion);
et_identifiant = (EditText) findViewById(R.id.et_id);
et_password = (EditText) findViewById(R.id.et_mdp);
et_password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
b_connexion.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("testId", et_identifiant.getText().toString());
Bundle bundleATransmettre = new Bundle();
bundleATransmettre.putString("id", et_identifiant.getText().toString());
Intent intent_interprete = new Intent(MainActivity.this, MenuInterprete.class);
Intent intent_interpretariat = new Intent(MainActivity.this, MenuInterpretariat.class);
intent_interprete.putExtras(bundleATransmettre);
intent_interpretariat.putExtras(bundleATransmettre);
try {
mdpInterprete = unInterpreteDAO.getInterprete(et_identifiant.getText().toString()).getPASSWORD();
} catch (NullPointerException e){
}
try {
mdpAdmin = unAdminDAO.getAdmin(et_identifiant.getText().toString()).getPASSWORD();
} catch (NullPointerException e){
}
if(et_password.getText().toString().equals(mdpInterprete))
{
et_password.setText("");
startActivity(intent_interprete);
}
else if(et_password.getText().toString().equals(mdpAdmin)) {
et_password.setText("");
startActivity(intent_interpretariat);
}
else {
Toast.makeText(MainActivity.this, "L'identifiant ou le mot de passe est incorrecte", Toast.LENGTH_LONG).show();
}
}
});
}
}
正如我所说,当你以管理员身份登录时,你可以向用户发送请求,用户可以看到他收到的请求列表。我想在用户收到新请求时向其发送一个通知,然后当用户单击通知时,通知将转到活动,用户可以在其中查看所有请求。
但是我不知道怎么做,因为我只需要在你以用户身份登录并且即使你关闭了应用程序的情况下发送通知
你能帮我吗
(对不起我的英语,我是法国人)请求来自哪里?互联网还是本地服务? 如果是从互联网,你需要一个服务器发送消息到客户端; 如果您想通知用户(即使应用程序已关闭),则必须创建服务以发送通知