Installing application without icon or activity - java

I had a discussion with a friend and he told me that some applications can be installed on android without any activity or icon showed in menu. Because i'm studying android too i was surprised because i never heard of that.
App's name is showed in "Manage Applications" section and its easy to uninstall it.
So now i'm asking as programmer. How is possible(if it is) to install that kind of application? (with no activity or launcher ).

Just remove all of the following intent filters from your manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Keep in mind though that from Android 3.1 onwards, your app will not receive any broadcasts, or be listed in any other places where an intent filter would make it available (like in the share menu) if the user hasn't manually opened your app UI (main Activity) at least once from the launcher.

There is another way that works even on Android3.1+ .You can not disable the icon itself, but you can disable one component of an application. So disabling the applications launcher activity will result its icon to be removed from launcher.
The code to do this is simple:
ComponentName componentToDisable =
new ComponentName("com.helloandroid.apptodisable",
"com.helloandroid.apptodisable.LauncherActivity");
getPackageManager().setComponentEnabledSetting(
componentToDisable,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
There is a few things to know about this solution:
1-the disabled component will not be launchable in any way
2-other non disabled activities will be launchable from other applications
3-an application can only disable its own component. There is a permission "android.permission.CHANGE_COMPONENT_ENABLED_STATE", but it wont work, 3rd party plications can not have this permission
4-the icon will only disapper when the launcher is restarted, so likely on next phone reboot, forcing the launcher to restart is not recommended
In this way,App must be run atleast on time.
Reference:
Removing an app icon from launcher

Yeah this kind of application is possible. You have to create an Application that has no Launcher Activity in the Manifest file.
For eg:- You can register a Broadcast for on boot received. So, that when the device boots your application will be called though it doesn't have any UI. You can checkout this one.
NOTE - This type of Application will only work below 3.1.

Related

Tile only application

Having seen the questions about activities with no GUI here, here and here. In addition, these answer are rather old, I don't know if they're still relevant.
I want to create an app for which the only user interaction is a quick tile.
I understood there can't be no activity at all, so I have a blank activity with no display using #android:style/Theme.NoDisplay
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service
android:name=".AdaptativeSleepTile"
android:icon="#drawable/ic_launcher_background">
</service>
But the app appears in my app list (with nothing happening when I click it, logically), which is not what is written in the comments of this answer.
I can't remove the line <category android:name="android.intent.category.LAUNCHER"/> otherwise I get the error message
Could not identify launch activity: Default Activity not found
Error while Launching activity
So what should I do to have a service for which the only user interaction is the quick tile? (Same question would also apply for no interaction at all, or only widget I guess)
Using Android Studio 4 and Sdk 29
I want to create an app for which the only user interaction is a quick tile.
That may or may not be practical. Since Android 3.1, apps are installed in a "stopped state", and it takes an explicit Intent to move them out of the stopped state and allow them to run. Normally, that comes from the user tapping on an icon in a launcher to run your MAIN/LAUNCHER activity.
It is possible that simply having a TileService available in the manifest is enough to get you listed in the notification shade, and the act of adding the tile will be enough to move your app out of the stopped state. However, I certainly cannot guarantee that, and it would not surprise me if this does not work.
Also, please bear in mind that you may need an activity for other reasons:
To display your terms of service
To display your privacy policy
To provide access to tech support
To allow for configuration of the app
And so on
But the app appears in my app list (with nothing happening when I click it, logically), which is not what is written in the comments of this answer.
If you mean the first comment, that is simply wrong, as is pointed out by other comments on that answer.
I can't remove the line otherwise I get the error message
I assume that you are getting that from Android Studio. You will need to change your run configuration to not try starting an activity.
Same question would also apply for no interaction at all
Fortunately, there is no solution for that. Malware authors think that totally invisible apps are wonderful, and Android takes steps to prevent such apps from being able to work. And, this is why I would not be surprised if you need an activity for your TileService.

Set app as default Assist Intent

So currently at my wits end for this issue.
I am trying to set my app as the default app launched when long pressing the Home button.
I am doing this by:
Setting Intent Filters in the manifest (I also experimented with adding MAIN and LAUNCHER action/category tags)
<action android:name="android.intent.action.ASSIST" />
<action android:name="android.intent.action.SEARCH_LONG_PRESS" />
<category android:name="android.intent.category.DEFAULT" />
Requesting the default app on an intent to allow users to change (there's also one for the Search Long Press action)
Intent intent = new Intent(Intent.ACTION_ASSIST);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
This approach works perfectly fine for devices running pre 6.0 software.
On post 6 devices the request is asked but the default assistant app is unchanged.
My app can be set as the default home app on post 6 devices perfectly fine when using these exact steps.
I'm unsure as to whether there's some kind of specific permission I'm missing or something. Nothing seems to work at all. The google app will always be used on long press. If I disable the google app then my app will run on long press.
Extra information: This is a kiosk app for business so I prefer to not have to disable the Google app for every single device this will go on. I don't mind if solutions are hacky as this is not going on the app store.
To implement your Assistant like app, the assistant app must provide an implementation of VoiceInteractionSessionService and VoiceInteractionSession.
It also requires the BIND_VOICE_INTERACTION permission.
See also:
Implementing Your Own Assistant
VoiceInteraction sample app

How to customize Android Google Setup Wizard for device owner provisioning?

--Use case:
1-System app apk in priv-app folder to be used as device owner.
2-User starts up device and Google setup wizard comes up.
3-Immediately starts device provisioning activity.
--Things that used to work:
This method used to work on Android 6.0 Marshmallow using the action intent:
<activity android:theme="#style/InvisibleNoTitle" android:name="OwnerActivity" android:launchMode="singleTop" android:immersive="true">
<intent-filter android:priority="5">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
without any problem.
After updating to Android 8.1 Oreo, this method no longer works. The OwnerActivity shows up only after setup wizard finishes which is useless since device is already provisioned by user and can't be provision again.
Is there any newer way of doing this so that my OwnerActivity shows up first to provision the device? What is changed in Oreo?
This is a bit late for an answer, and without talking to Google it's a little hard to see what the design decisions have been. However, what we can know is what's changed.
1. android.intent.action.DEVICE_INITIALIZATION_WIZARD is deprecated atleast as early as Oreo.
2. Package Manager Service has had changes to reference the setup wizard. The new approach appears to be the category android.intent.category.SETUP_WIZARD which your manifest definition lacks.
Reading the comments around the code (which you can find below) we see this log:
Slog.e(TAG, "There should probably be exactly one setup wizard; found " + matches.size()
+ ": matches=" + matches);
https://android.googlesource.com/platform/frameworks/base/+/nougat-mr2.3-release/services/core/java/com/android/server/pm/PackageManagerService.java#17872
So it seems like as of Nougat, Android doesn't support having multiple setup wizards that are chained together.
For your specific problem of how to setup the device admin I have 2 suggestions.
If you care about CDD and CTS then you should get your users to go through the Google device owner provisioning process which they keep updated.
If you don't care about that and you just want your build to always have a device owner, just make changes in the frameworks or add some system binary that always runs before the setup wizard which will set your device owner application for you.

Home button override in android. Issue in start up when reboot the phone

I am trying to open a application when I click the Home Button. To do that I used in AndroidManifest.xml the next lines:
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
So the first time I click in home button the system ask me: to go to home page or to go to my application, and then to choose one time or always.
I choose always because always I click in Home Button I want to start my application, then i click back and i go back to home screen.
But there is a problem. When I reboot the phone. Turn off then turn on, the first thing the system make is launch my application and not go to home screen. I want to avoid that off course. At this time I can only avoid if I choose to start my application one time but that is not what i want.
There is some code to add to block the application to run when I turn on the phone?
If i choose always my app I block in my app in start-up phone and need to go to definitions to erase the app to make possible to go to homescreen.
I have tried to install "StartUp Manager" app to erase my app from start up but my app dont apper in user tab. There are some options in System tab but i dont know what to choose or even if it works.
Any advice?
The answer is that you can't
The launcher application is exactly that, literally - first to launch when the phone boots and the one to launch when a user presses the HOME button no matter where or during the runtime of what application.
#strider 's code will give you an event to intercept and do something when the device finishes boot but it will not replace the launcher with the default launcher.
The only way i know of to badly mimic what you're asking is to use that event and launch the default launcher application but that is an ugly hack which will require the user to authorize the default launcher every time.
Every other option requires you to sign you launcher application with the system KeyStore in order to gain system permissions which would allow you to additional permissions but even that will not provide you with all that you're asking for.
Sorry.
My first answer was bad, srry, I think I misunderstood your question.
Maybe this is a better idea:
Use a broadcast receiver to see if device has just booted
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
and the receiver:
<receiver android:name="com.example.MyBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
and the MyBroadcastReceiver.java :
public class MyBroadcastReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// Device just booted (close your app or something) so it will show homescreen
}
}

Android app deploy on eclipse creating duplicate

Whenever I Run an Android app on my phone (even when the application has not been installed before), the application is shown duplicated in the app drawer. This started happening right after I setup a Splash Screen activity, and I find it kind of annoying. One of the apps in the launcher install with the SplashScreen Activity, the other one does not. The app works without issues, but is there a way to remove this duplicate app icon in the drawer?
It's not urgent, but maybe you guys know ;)
I run my Android app projects with Eclipse, if it's of any help.
Any ideas? Oh, and if you guys need me to show you some of my code, please tell me.
I followed this tutorial for the creation of my splash screen.
Be sure to only have this:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
at one Activity, in your manifest.xml

Categories

Resources