Search code examples
androidwidgetadb

Launch Android widget via ADB


I would like to launch the Android weather widget.

The package is:

com.sec.android.widgetapp.ap.hero.accuweather

I tried many different versions of

adb shell am start .....

but was not successful. Does anyone know how to do it?


Solution

  • The command, for starting an activity in adb shell using a component name, is:

    am start -n package/activity

    So, in your case specifically, simply launch adb shell and enter the command as follows:

    > am start -n "com.sec.android.widgetapp.ap.hero.accuweather/com.sec.android.widgetapp.ap.weather.detail.DetailActivity"
    

    If you want to start this in Android programmatically, you may do the following:

    Intent intent = new Intent(); 
    intent.setComponent(new
    ComponentName("com.sec.android.widgetapp.ap.hero.accuweather", "com.sec.android.widgetapp.ap.weather.detail.DetailActivity"));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    
    if (intent != null && intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent); 
    }