Manifest.xml
------------------------------------------------
<activity android:name=".pushnotification.NewMsgDialogActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
MyFirebaseMEssagingService.java
------------------------------------------------
final Intent intent = new Intent(MyFirebaseMEssagingService.this, NewMsgDialogActivity.class);
intent.putExtra("trainerId", trainer_id);
intent.putExtra("trainer_image_str", trainer_image_str);
intent.putExtra("trainer_name", trainer_name);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(MyFirebaseMEssagingService.this, 0, intent, 0);
try {
// Perform the operation associated with our pendingIntent
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
NewMsgDialogActivity.java
------------------------------------------------
public class NewMsgDialogActivity extends Activity {
String trainerId, trainer_name, trainer_image_str = "";
public static String new_msg = "";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
show_new_msg_dialog();
}
public void show_new_msg_dialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(getResources().getString(R.string.new_msg))
.setCancelable(false)
.setIcon(R.drawable.messages_icon)
.setMessage(NewMsgDialogActivity.new_msg)
.setNegativeButton("Ignore", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface, int i) {
dialoginterface.dismiss();
finish();
}
})
.setPositiveButton("Check", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface, int i) {
goto_voice_msg_activity();
dialoginterface.dismiss();
finish();
}
}).show();
}
@Override
public void onBackPressed() {
super.onBackPressed();
finish();
}
}
No comments:
Post a Comment