Android app deploy on eclipse creating duplicate - java

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

Related

Why installed app got hidden in app drawer?

I have installed an app via Android Studio but it got hidden due to adding Browsable in manifest.
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="myapp"
android:scheme="returns"
android:pathPattern="/backToApp" />
These are the lines i used to navigate back to app from browser. If i comment out these lines then app icon shows in app drawer.
Can somebody explains what and why it does that?
I agree, android.intent.category.BROWSABLE is causing headaches to Android developers for a long time. Unfortunately, no one really knows the exact reason why "App Icons" dissapear. However, you could certainly solve the problem by having multiple manifest declarations: Please check out these links.
App Launcher Icon Disappears from screen
How to fix not show application icon into app drawer?
App icon doesn't appear after implementing deep links to my app
Let me know if you have any questions.
PS: I am not kidding, really, the reason behind this issue is still a mystery.

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.

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.

Installing application without icon or activity

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.

Run application in the background

I'm trying to start the GroomDroid web server in Android but when it starts, a black window is shown.
I'd like to start this app in the background without that screen being shown.
I'm starting this app in the following way:
Intent webServer = new Intent();
webServer.setClassName("net.allory.groom","net.allory.groom.GroomDroid");
startActivity(webServer);
I also tried with startService(webServer); but it doesn't seem to work.
Can anybody help me with that ?
You should move your background logic to a service, and when it's running create an ongoing notification.
Selecting that notification should start your activity (ui), and the service can communicate its data to it using a Handler.
Also, if you specify the launchMode of your activity to singleTask:
<activity android:name=".activity.YourActivity"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true"
android:clearTaskOnLaunch="false"
android:finishOnTaskLaunch="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
and on application start check if your service is already running (say you've already started the application, and now press its icon again), you'll be able to start the very same task, instead of relaunching your service and/or showing nothing.
This explanation might be not too clear, let me know if you need more details :)
Lince,
Looks like the emulator. If you are using eclipse go to the 'Run Configurations...' and change the 'Launch Actions' to 'Do Nothing'
Do you want the app to always be headless?
Frank

Categories

Resources