Now Playing Card Does Not Start the Desired Activity

好久不见. 提交于 2019-12-24 15:23:42

问题


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");
}

来源:https://stackoverflow.com/questions/30053596/now-playing-card-does-not-start-the-desired-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!