Sending intent with bundle using console

前端 未结 3 1051
予麋鹿
予麋鹿 2020-11-29 12:36

I\'m developing an Android app listening for specific intent containing a bundle with some data. I would like to send an intent to my app using adb. I have tried with:

3条回答
  •  执念已碎
    2020-11-29 13:13

    I was facing the same issue, trying to fake the situation where you've just installed an app after receiving a Facebook App Invite. Couldn't get the shell to work, ended up building a really simple test rig that had one button and handler code like:

        Button button  = (Button)findViewById(R.id.trigger_button);
        button.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                intent.setData(Uri.parse("myapp://fb-app-invite"));
    
                Bundle bundle = new Bundle();
                bundle.putString("target_url", "myapp://fb-app-invite?fromuser=673");
                intent.putExtra("al_applink_data", bundle);
    
                MainActivity.this.startActivity(intent);
            }
        });
    

提交回复
热议问题