Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Things intent for boot

When I reboot after deploying an application to Android Things the application doesn't start.

Is there a specific intent to start an application on boot?

like image 769
proppy Avatar asked Dec 13 '16 17:12

proppy


People also ask

What can intent be used for Android?

An intent is to perform an action on the screen. It is mostly used to start activity, send broadcast receiver,start services and send message between two activities. There are two intents available in android as Implicit Intents and Explicit Intents.

What is intent extras in Android?

We can start adding data into the Intent object, we use the method defined in the Intent class putExtra() or putExtras() to store certain data as a key value pair or Bundle data object. These key-value pairs are known as Extras in the sense we are talking about Intents.

What is content intent in android?

Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc.


2 Answers

Add to AndroidManifest.xml

Developer Preview 0.8 and greater (New Style)

<intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.HOME"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

Before Developer Preview 0.8 (Old Style)

<intent-filter>
   <action android:name="android.intent.action.MAIN"/>
   <category android:name="android.intent.category.IOT_LAUNCHER"/>
   <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

See Android Things Release Candidate 16 April 2018

like image 182
fishjd Avatar answered Oct 29 '22 01:10

fishjd


If your Android Things device has multiple applications installed that all have this intent filter in the manifest:

<intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.HOME"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

( < DP8 used to need IOT_LAUNCHER that has been deprecated)

Then your application will not start by default, instead the Intent Chooser dialog will be shown and the system will wait for user input to select which app to run. (This happens wether or not you have an actual display plugged in. If you don't have a display it might appear as tho the device is just hanging.)

I wrote a script here: https://gist.github.com/blundell/7c0c3bb17898b28fe8122b0dc230af50 that will uninstall all applications that have the above Intent Filter so that you can start again and only have 1 application installed - therefore this application will start on boot.

script to uninstall example


With the latest version of AndroidThings the IntentChooser will not be shown anymore, however the problem can persist as one of the apps installed is selected to open and the others do not.

like image 17
Blundell Avatar answered Oct 28 '22 23:10

Blundell