Transferring Intent Using a Pool Using the Console

I am developing an Android application that is looking for specific intentions containing a set with some data. I would like to send an intent to my application using adb. I tried with:

adb shell am startservice -a com.INTENT_NAME -e myBundleName myBundleData com.pkg/com.pkg.cls 

but my application recognized it as a list of strings, not a set. Does anyone know how to send an intent using packages using the am app? Unfortunately, the documentation says only about sending lists of strings or numbers, nothing about the package.

+2
source share
3 answers

According to the source code, am cannot accept bundle type input

Update: In Android 7.0, the intent analysis parameter code has been moved from Am.java to Intent.java and supports additional data types (for example, Array[] and ArrayList<> main types). Unfortunately, the am command still does not support additional information such as the Bundle .

+7
source

I ran into the same problem trying to fake a situation where you just installed the application after receiving an invitation to participate in Facebook. It was not possible to make the shell work, as a result, a really simple test installation was built, in which there was 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); } }); 
0
source

You can run it using the following command: adb shell am startservice -a android.intent.action.MAIN -e "key" "value" -n com.example.test / .TestService The key and value should be your package values, which you want to send. TestService should be your ServiceName Add for your service in androidmanifest.xml Snippet:

 <service android:name=".TestService" android:enabled="true"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </service> 
-1
source

Source: https://habr.com/ru/post/988489/


All Articles