How to get back to initial app where the implicit intent is started?

给你一囗甜甜゛ 提交于 2019-12-11 07:16:57

问题


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.

my button code is:

          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;

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//


回答1:


Instead of startActivity use startActivityForResult. You can even override onActivityResult method to know when the user returned from other activity.



来源:https://stackoverflow.com/questions/23579725/how-to-get-back-to-initial-app-where-the-implicit-intent-is-started

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