Android hidden application - android

I'm writing a (legal) spy program. I want to make this program hidden on the launcher (so that no icon is shown). I tried to remove <category android:name="android.intent.category.LAUNCHER" /> line from AndroidManifest.xml, but then the user can't launch the application in first start mode (configuration). Who have any ideas ?
How can I do it?

You need to make your app into a service. Here is Androids take on creating services components:
http://developer.android.com/guide/components/services.html
Found this as well on MobiWare:
When you want to track the usage of the mobile or gather some data without user knowledge,this might help you.
Step1: Create an application with No icon.
Normally,an activity is declared as follows in manifest.
<activity
android:label="#string/app_name"
android:name="org.security.tracker.Tracker-activity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Remove the Category TAG ,you wont get app icon anymore.
Now,you don't need activity anymore. so remove this segment.
BUt you might think,how the app will run without any trigger or what is the starting point of the application.
This is the solution.
<!-- Start the Service if applicable on boot -->
<receiver android:name="org.security.tracker.ServiceStarter" >
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
This triggers your code that written in Receiver there by you can run service to implement your thoughts.
<service android:name="org.security.tracker.serviceCode" />
You need to add this permission,
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Your code runs when the phone reboots only.
Step 2. Write your code
On Reboot,the recevier will fire ,there you can start your service.
class ServiceStarter extends BroadcastReceiver {
#Override
public void onReceive(Context _context, Intent _intent) {
Intent i = new Intent("com.prac.test.MyPersistingService");
i.setClass(_context, ServiceCode.class);
_context.startService(i);
}
}

You can remove the <category android:name="android.intent.category.LAUNCHER"/> from the AndroidManifest.xml file.
But remember to add <category android:name="android.intent.category.LEANBACK_LAUNCHER"/> so that Android studio will be able to compile your app (yet hidden from launcher) :) :D

remove
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
from the manifest file

The app can be hidden programmatically, Below is the code which will hide the app from the Launcher menu. this works fine android 10 as well
// App will be hidden when this method will be called from menu
private fun hideApp() {
val packageManager =packageManager
val name =ComponentName(this,MainActivity::class.java)
packageManager.setComponentEnabledSetting(name,PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP)
Log.d("TAG", "hideApp: success")
}
For more information, you can check this link https://developer.android.com/reference/android/content/pm/PackageManager#setComponentEnabledSetting(android.content.ComponentName,%20int,%20int)

Related

Android App name is not displayed in the multitasking screen

I've developed a simple NFC application that reads and displays the data(NDEF Records) present in the NFC tag. I modified the Manifest file so that whenever a tag gets tapped, my app gets opened.
Now the problem is when I manually open the app and check the multitasking screen, it displays my app name i.e NFCReader but when the app gets opened itself when a tag comes in contact with the device, my app gets opened but when I check the multitasking screen, it doesn't display my app name. Instead it displays NFC Service. What should I do to overcome this issue?
I assume that you have set your activity declaration, in your manifest, to something like this:
<activity
android:name=".packagename.MainActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"
android:theme="#style/AppTheme.Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="domain.com"
android:scheme="http" />
</intent-filter>
</activity>
I think the answer to your question is the following line of code that you forgot to add:
android:launchMode="singleTask"
I invite you to read about launch modes here and here.
Please note: This answer is based on the use of Reader mode API, otherwise check this answer.
Hope this helps!

Application Error: The protocol isn't supported (cedemo://com.example.scheme.MainActivity)

Phonegap Application lunching Problem
it is manifest file:
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<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" />
<data
android:scheme="cedemo" android:host="com.example.shcema.MainActivity"/>
</intent-filter>
</activity>
it is my main activity:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}}
But when I click "Launch Application" link then i get this alert.
please, help me any one.
You missed CATEGORY_BROWSABLE in your intent-filter.
Quote from Android Docs:
Activities that can be safely invoked from a browser must support this category. For example, if the user is viewing a web page or an e-mail and clicks on a link in the text, the Intent generated execute that link will require the BROWSABLE category, so that only activities supporting this category will be considered as possible actions. By supporting this category, you are promising that there is nothing damaging (without user intervention) that can happen by invoking any matching Intent.
So your intent-filter must be like:
<intent-filter>
<data android:scheme="cedemo" android:host="com.example.shcema.MainActivity"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
See more at : Make a link in the Android browser start up my app?
This won't work. because how Android can know which App I've start on this custom URI call?
So you first have to let the android know that a custom URI exists which can receive such calls and then whenever that custom URI is invoked by any app either native or hybrid, OS will automatically forward it to the registered app i.e. able to receive such calls.
Read this Android docs tutorial:
Allowing Other Apps to Start Your Activity
http://developer.android.com/training/basics/intents/filters.html
Here is an example how one app can call other app. Launch an application from another application on Android
And here is custom plugin which makes easier to open another app from the Cordova/phonegap App.
https://github.com/lampaa/org.apache.cordova.startapp

Preventing main activity from being launched if running already

I have an application that is launched via an intent-filter action. The problem is that every time the event/ action occurs, Android displays a dialog asking to launch the app even if it is already started.
I want the behavior to be as follows:
User asked to launch the app if app is not open.
Dialog does not display if app is running in the foreground.
Is there a way to achieve both of these goals? I am targeting Android 4.0.
edit
Here is my intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
android:resource="#xml/device_filter" />
You need to set the Activity's launchMode to singleTask. You can do this by adding the activity attribute in your Android Manifest:
android:launchMode="singleTask"
See the documentation for more details.
Use flags when asking the user to start the application. Set the flag when this is first enabled and each time check if this flag is ticked. For example if (flag == 1) askusertostart() else continue; if this is clear to you?

Android app needs to be auto-restart after the phone power On

I need my app to be started automatically once after the phone reboot and Power-on.
I used the code provided at AutoStart an Application at boot up and now my android app starts automatically after the phone reboot (restart).
Now, consider that instead of doing a phone reboot, I have used Phone power off (Shut phone down) option. After the phone power on, my app is not started automatically as expected. Can you please explain what I have missed.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:enabled="true" android:name=".BootUpReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
public class BootUpReceiver extends BroadcastReceiver
{
private static SharedPreferences aSharedSettings;
#Override
public void onReceive(Context context, Intent intent)
{
aSharedSettings = context.getSharedPreferences("MYPreferences", Context.MODE_PRIVATE);
boolean isUserLoggedIn = aSharedSettings.getBoolean(kEY.AUTHENTICATED, false);
if(isUserLoggedIn)
{
Intent aServiceIntent = new Intent(context, HomeView.class);
aServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(aServiceIntent);
}
}
}
Thank You.
Does it work as intended if you launch the application manually at least once before rebooting the phone, and not 'Force-close' it?
Have a look at:
Android : android.intent.action.BOOT_COMPLETED on ICS and Gingerbread
Boot Completed Regression Confirmed
There are a few things you can try.
Firstly check that your app installLocation in the AndroidManifest.xml is set to android:installLocation="internalOnly" this makes sure that the app is on the local storage. Apps installed to the sdcard will not receive the BOOT_COMPLETE intent.
Also I would remove <category android:name="android.intent.category.DEFAULT" /> it is not necessary.
And the last thing you can try is using a full package name:
<receiver android:enabled="true"
android:name="com.myapp.receivers.BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Try to add
<category android:name="android.intent.category.LAUNCHER" />
instead of
<category android:name="android.intent.category.DEFAULT" />.
And also check the value of isUserLoggedIn.
Are you using a HTC device? If so, you may have a feature enabled called "Fast-Boot"
See this link for details.
Detect if HTC "Fast boot" is enabled
the name of the Activity from where you are starting your application, Add this line in your tag.....And let me know it worked or not
<category android:name="android.intent.category.HomeView" />

adding custom action won't start the activity when running it in the emulator

I have the following code in my Manifest:
<activity android:name="com.fletech.android.apparent.CategoriesGrid"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
When I run the app in Eclipse it starts this activity in the emulator, as expected.
But when I also add:
<action android:name="com.fletech.android.apparent.action.APPARENT_MAIN" />
right below the other action, and run the app, it only installs it to the emulator but doesn't run it. Why?
What I wanted to achieve is this: I would like to be able to show a dialog to the user (from another apps) to chose between all my apps that have "com.fletech.android.apparent.action.APPARENT_MAIN" as an action.
If you want to specify another launch scenario, you should just add another whole intent-filter block rather than putting all of the action clauses in the same one.

Categories

Resources