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?
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.
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.
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
The following intent-filter needs to be added to AndroidManifest.xml
<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>
Have you tried their demo app? Try out this first before writing your own app. This should work as expected. Later change as you want.
Just don't remove this part from the AndroidManifest.xml of your code.
<!-- Launch activity automatically on boot -->
<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>
To give Android Things support in app, We need to define main entry point for the system to automatically launch on boot.
While adding an intent filter for an activity must contain an intent filter that includes both CATEGORY_DEFAULT and IOT_LAUNCHER.
<application
android:label="#string/app_name">
<activity android:name=".HomeActivity">
<!-- Launch activity as default from Android Studio -->
<!-- For ease of development, this same activity should include a CATEGORY_LAUNCHER intent filter so Android Studio can launch it as the default activity when deploying or debugging. -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Add below intent filter which enable android things support for app -->
<!-- Launch activity automatically on boot -->
<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>
</activity>
Check Home activity support for Android Things in android app.
Answer from user fishjd, help me. If that didn't work, try deleting app using adb, and reinstalling it
adb uninstall <packet>
Related
I made an browser app for android and i want to make it available as browser app so i can choose it as default phone browser.
I have tried some intent filters but that did not work for me. I only can send texts or links to my application an it will open it but i want to make it choosable as default browser
What do i have to do? Please suggest me!!
Have you add the "action" attribute in manifest, with value "ACTION_VIEW" ?
add intent filter in your main activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
and then, when click link in other app,your app will be in the popup chooser,
choose it as default。
I recently started testing my react-native android application and noticed that it doesn't create an app icon on installation. When I debug - it seems to install and run fine, but when I look for it in the app icon to launch - it does not show up. Looking at the list of installed apps, it's there. How can I debug this? Do I need to change the launch mode from singleTop to something else? I tried changing it to singleInstance and it still had the same issue. If I remove some of the intent filters it seems to work - so maybe I messed up the branch.io installation instructions? Do I need to create a seperate intent filter xml node for the other intents? https://dev.branch.io/getting-started/sdk-integration-guide/guide/react/#android-configure-manifest
AndroidManifest.xml
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.foo.com"
android:pathPrefix="/event" />
<!-- note that the leading "/" is required for pathPrefix-->
<data android:scheme="fooapp" android:host="open" />
</intent-filter>
<intent-filter>
<action android:name="fcm.ACTION.EVENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Update
Splitting up the intent-filters seems to have fixed it - but a bit unclear if that is the correct thing to do. In the branch.io instructions - did they mean for me to create a new intent-filter and not add to the existing main one?
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.foo.com"
android:pathPrefix="/event" />
<!-- note that the leading "/" is required for pathPrefix-->
<data android:scheme="fooapp" android:host="open" />
</intent-filter>
The launcher is typically specific software developed by the individual hardware manufacturers. On all of the devices i have, an app does not get installed on the homescreen when it is not installed from the play store, but it does show up in the list of apps. However, that behaviour will be specific to the launcher you are using i think.
You should not need to go to settings->apps though just to see it. Is that the problem you are having?
Perhaps a screenshot as well as a description of your test device (s) would make the question clearer.
Update....
Typically the startup activity has one intent filter with only MAIN and LAUNCHER. I would just try to remove the other things from that intent filter and see if that resolves the problem. Then one by one, add the rest of the things you have listed until you identify the problem child.
Looking at this again, I am not sure that you can define 2 actions in a single event filter. So it seems you need to remove VIEW.
I designed one Application in Android. When i upload this Application on device, it will display three icons of that application.
Which part of Android Manifest File is responsible to display the icon.Any idea?
Go to the manifest and remove the launcher intent from all activities but one
Only a single activity - the one you want opened when the user clicks the homescreen icon - should have the following intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
See your AndroidManifest file. How many activities you have with next code:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
You must have 3 activity for this case.
Also this is may be last package name of your project before you rename it.
See here Manifest file
android:icon="#drawable/ic_launcher"
And
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
in my first activity I have two intent filters.
The first one is for regular access from the launcher. The second one is used when a user tries to unzip a file.
android:name=".MyApplication">
<activity
android:name=".SplashActivity"
android:label="#string/app_name"
android:icon="#drawable/ico"
android:theme="#style/Theme.Sherlock.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.ALTERNATIVE"/>
<data android:mimeType="application/zip"/>
</intent-filter>
</activity>
The problem is that in the launcher I get two icons instead of one .
How can I get only one icon and mantain the ability to run the activity with the second intent filter. I have tried removing (or changing to a different category)
<category android:name="android.intent.category.ALTERNATIVE"/>
Thanks
EDIT:
The problems seems somehow related with Android Studio (v 0.1.6 and 0.1.7) as
with Eclipse only one icon shows up.
Each manufacturer makes a custom build of Android. Is this modification done in source or is it in app ?
If its in source : pointers to appropriate links would be useful.
It's called a launcher, which is a normal APK application. It's a normal Activity which reacts to a certain Intent.
You can create another one, and install it on your phone. When you press the home button it will ask which Launcher to use.
<activity
android:label="#string/app_name"
android:name=".ClassNameOfYourLauncher">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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>
</activity>
I think you're talking about the Launcher. That's the first thing which comes to my mind. Its a System apk which will be there in app folder in system directory. If you need to modify that, you better create a new launcher of your own. Here is a link on how to go about doing that.