RadioPlayerService icon indicating copy to clipboard operation
RadioPlayerService copied to clipboard

Notification does not open activity

Open igor-dmd opened this issue 8 years ago • 5 comments

Hi there! I just noticed that the notification menu does not open up the activity when it' clicked. For example, if you click on the "home" button on your device and the notification is still on, I want to be able to click on it and navigate back to my app. After clicking the system menu still closes, but nothing happens after that (I believe that happens on most of the apps before the actual activity is opened). Need some help!

igor-dmd avatar Apr 14 '16 18:04 igor-dmd

I also saw that notification remains opened even after the app gets closed. And I'm not having access anymore to the enableNotification method to fix this. =(

igor-dmd avatar Apr 14 '16 18:04 igor-dmd

you need change "RadioPlayerService.java", because "onStartCommand" method can't word; need change "PendingIntent" for "getBroadcast" , then, you can listen this broadcast on you activity to launch anything.

a442509097 avatar Aug 01 '16 01:08 a442509097

???

mahmooddagga avatar Aug 15 '16 20:08 mahmooddagga

Same problem here. Have you find any solution? Do you have any plans to update? Thank you!

idesignzone avatar Sep 29 '16 03:09 idesignzone

That worked for me hope it helps :)

in the manifest file:

        <receiver android:name=".MyBroadcast">
            <intent-filter>
                <action android:name="co.mobiwise.library.notification.radio.INTENT_OPENPLAYER" />
            </intent-filter>
        </receiver>

in MyBroadcast BroadcastReceiver:

 @Override
    public void onReceive(Context context, Intent intent) {
        if (!isAppForground(context)) {
            Intent newIntent = new Intent();
            newIntent.setClassName("com.my.package", "com.my.package.MyActivity");
            newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            context.startActivity(newIntent);
        }

    }

    public boolean isAppForground(Context mContext) {

        ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
        if (!tasks.isEmpty()) {
            ComponentName topActivity = tasks.get(0).topActivity;
            if (!topActivity.getPackageName().equals(mContext.getPackageName())) {
                return false;
            }
        }

        return true;
    }

and finally added :

else if(action.equals(NOTIFICATION_INTENT_OPEN_PLAYER)){
            Intent i = new Intent("co.mobiwise.library.notification.radio.INTENT_OPENPLAYER");
            sendBroadcast(i);
        }

to onStartCommand method in RadioPlayerService.java in the library.

hamdiwanis avatar Mar 22 '17 20:03 hamdiwanis