-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
PushHandlerActivity.java
47 lines (37 loc) · 1.35 KB
/
PushHandlerActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package firebase.cloudmessaging;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
public class PushHandlerActivity extends Activity {
private static final String LCAT = "FirebaseCloudMessaging";
@Override
public void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
finish();
CloudMessagingModule module = CloudMessagingModule.getInstance();
Context context = getApplicationContext();
String notification = getIntent().getStringExtra("fcm_data");
if (module != null) {
module.setNotificationData(notification);
}
Intent launcherIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
assert launcherIntent != null;
launcherIntent.addCategory(Intent.ACTION_MAIN);
launcherIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
launcherIntent.putExtra("fcm_data", notification);
startActivity(launcherIntent);
} catch (Exception e) {
// noop
} finally {
finish();
}
}
@Override
protected void onResume() {
Log.d(LCAT, "resumed");
super.onResume();
}
}