Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Intent to App in Emulator

Is it somehow possible to send automated intents to an app inside an emulator for testing?

I have a list of all my intents and I want to test them automaticily, so is it possible to just do a adb shell <myfancycommand> android.intent.action.PACKAGE_ADDED to initiate the android.intent.action.PACKAGE_ADDED action on the device? Or do I have to write a script that calls all the stuff by its own, so for example for this intent install a dummy apk on the device?

like image 597
reox Avatar asked Apr 23 '12 09:04

reox


People also ask

How do I send Intent to another app?

Intent shareIntent = Intent. createChooser(sendIntent, null); startActivity(shareIntent); Optionally, you can add extras to include more information, such as email recipients ( EXTRA_EMAIL , EXTRA_CC , EXTRA_BCC ), the email subject ( EXTRA_SUBJECT ), and so on.

What is the use of Intent createChooser () method?

createChooser(intent, title); // Try to invoke the intent. // Define what your app should do if no activity can handle the intent. This displays a dialog with a list of apps that respond to the intent passed to the createChooser() method and uses the supplied text as the dialog title.

What is startActivity in Android?

Starting activities or services. To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent.

How do you call an Intent?

Intent Object - Action to make Phone CallIntent phoneIntent = new Intent(Intent. ACTION_CALL);


1 Answers

Even more simple is the use of the am application.

You can just run it like this from the adb shell:

# am broadcast android.net.conn.CONNECTIVITY_CHANGE
Broadcasting: Intent { act=android.intent.action.VIEW dat=android.net.conn.CONNECTIVITY_CHANGE }
Broadcast completed: result=0
# am broadcast android.intent.action.BOOT_COMPLETED
Broadcasting: Intent { act=android.intent.action.VIEW dat=android.intent.action.BOOT_COMPLETED }
Broadcast completed: result=0
like image 104
reox Avatar answered Sep 17 '22 15:09

reox