如何返回到隐式意图开始的初始应用程序? [英] How to get back to initial app where the implicit intent is started?
问题描述
我有一个包含一些按钮的应用程序.其中一些按钮通过android网络浏览器打开特定的URL/地址并关闭我的应用程序(隐式意图). 但是我想要这个,当用户关闭互联网浏览器时,android会自动将用户重定向到我的应用.
I have an app which contain some buttons.some of these buttons open specific URL/address by android internet browser and close my app(implicit intent). but i want this, when user close internet browser android redirect user to my app automatically.
我的按钮代码是:
case R.id.btnB:
Uri myurl1 = Uri.parse("http://www.justandroid.com/");
Intent intent_B = new Intent(Intent.ACTION_VIEW, myurl1 );
startActivityForResult(intent_B,8);
break;
case R.id.btnC:
Uri myurl2 = Uri.parse("http://www.loveandroid.com/");
Intent intent_C = new Intent(Intent.ACTION_VIEW, myurl2 );
startActivityForResult(intent_C,7);
break;
和onActivityResult中:
and in onActivityResult :
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==7)
{
//do what
}
if(requestCode==8)
{
//do what
}
这些代码很好用,但是如何将它们更改为我想要的.谢谢//
these code works good,but how to change them to what i want.thanks//
推荐答案
使用startActivityForResult
代替startActivity
.您甚至可以覆盖onActivityResult
方法,以了解用户何时从其他活动返回.
Instead of startActivity
use startActivityForResult
. You can even override onActivityResult
method to know when the user returned from other activity.
这篇关于如何返回到隐式意图开始的初始应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!