Commit 8adfea4f authored by Libin Lu's avatar Libin Lu Committed by GitHub

Merge pull request #449 from cooperka/patch-2

Support Android activity aliases
parents 3f5c41ed 613b3462
......@@ -41,16 +41,11 @@ public class FIRLocalMessagingHelper {
sharedPreferences = (SharedPreferences) mContext.getSharedPreferences(PREFERENCES_KEY, Context.MODE_PRIVATE);
}
public Class getMainActivityClass() {
public String getMainActivityClassName() {
String packageName = mContext.getPackageName();
Intent launchIntent = mContext.getPackageManager().getLaunchIntentForPackage(packageName);
String className = launchIntent.getComponent().getClassName();
try {
return Class.forName(className);
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
return className;
}
private AlarmManager getAlarmManager() {
......@@ -59,8 +54,8 @@ public class FIRLocalMessagingHelper {
public void sendNotification(Bundle bundle) {
try {
Class intentClass = getMainActivityClass();
if (intentClass == null) {
String intentClassName = getMainActivityClassName();
if (intentClassName == null) {
return;
}
......@@ -197,7 +192,8 @@ public class FIRLocalMessagingHelper {
mContext.sendOrderedBroadcast(i, null);
if(!mIsForeground || bundle.getBoolean("show_in_foreground")){
Intent intent = new Intent(mContext, intentClass);
Intent intent = new Intent();
intent.setClassName(mContext, intentClassName);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtras(bundle);
intent.setAction(bundle.getString("click_action"));
......@@ -232,8 +228,8 @@ public class FIRLocalMessagingHelper {
}
public void sendNotificationScheduled(Bundle bundle) {
Class intentClass = getMainActivityClass();
if (intentClass == null) {
String intentClassName = getMainActivityClassName();
if (intentClassName == null) {
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment