Now Playing Card Does Not Start the Desired Activi

2019-08-10 23:00发布

问题:

I could not manage to start an activity from the Now Playing card. I am using the following code, but the NowPlayingActivity never gets called.

    Intent intent = new Intent(getApplicationContext(), NowPlayingCardActivity.class);
    PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 99, intent, 
    PendingIntent.FLAG_UPDATE_CURRENT);

    mSession.setSessionActivity(pi);

and in the manifest file:

<activity android:name=".NowPlayingCardActivity" />


I am taken to the main activity when I click on the Now Playing card, and the NowPlayingCardActivity is not called.

NowPlayingActivity:

public class NowPlayingCardActivity extends Activity {

    public static final String TAG = "NowPlayingCardActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate");
        Intent newIntent;

        newIntent = new Intent(this, ChannelDetailsActivity.class);
        startActivity(newIntent);
        finish();
    }
}

Thanks in advance for any help...


Edit: I added the following code to NowPlayingCardActivity, but to no avail...

@Override
public void onResume() {
    super.onResume();
    Log.d(TAG, "onResume");

}

@Override
public void onStart() {
    super.onStart();
    Log.d(TAG, "onStart");
}