Finishing (or Accessing) a specific Activity in Android

独自空忆成欢 提交于 2019-12-02 08:01:49

try something like this

Intent i = new Intent();
    i.putExtra(EXTRA_KEY_ARTIST, id);
    i.setClass(this, ArtistActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    startActivity(i);

That's all when you set the the FLAG_ACTIVITY_SINGLE_TOP property it wont start a new activity but will show your activity intially created if its not destroyed yet,

But if your activity is the starting activity then you can put it like this

 <activity
    android:name=".ArtistActivity"
    android:label="Artist"
    android:launchMode="singleTop">
</activity>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!