brockoli
brockoli

Reputation: 4566

PendingIntent not launching app

I have a service running that will put a notification on the notification bar on a particular event. In that notification I'm setting a PendingIntent to launch another application. For some reason when I act on the notification it doesn't launch the other application. Here is the code where I create the PendingIntent.

private PendingIntent externalAppStartIntent(LaunchInfo launchInfo) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setClassName(launchInfo.getPackageName(), launchInfo.getActivityName());
    intent.setData(launchInfo.toUri());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    return PendingIntent.getActivity(this, ZONE_SERVICE_START_EXTERNAL_APP, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);
}

I am able to launch the app using a regular Intent elsewhere in my code like this.

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setClassName(packageName, activityName);
    intent.setData(data);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        ZoneUtils.launchMarketDialog(getActivity(), packageName);
    }

I've checked to make sure the values of the variables I'm sending in both cases are the same.

Note that I'm trying to launch an Activity in another application outside of the one where this code lives.

EDIT: Here is the activity definition from the other apps manifest.

    <activity
        android:name=".ui.GalleryActivity"
        android:configChanges="orientation">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="join"
                android:path="/"
                android:scheme="mgp" />
        </intent-filter>
    </activity>

EDIT2: Here is the log I get when I act on the notification

04-20 19:05:59.151: I/ActivityManager(193): START {act=android.intent.action.VIEW cmp=com.brockoli.magnet.photoapp/.ui.GalleryFragment bnds=[128,418][720,546]} from pid -1

Upvotes: 2

Views: 2452

Answers (1)

brockoli
brockoli

Reputation: 4566

David Suppiger spotted it!

I was accidentally passing my GalleryFragment instead of my GalleryActivity. Working great now! Ty

Upvotes: 1

Related Questions