简体   繁体   中英

android hide application from the list of applications and launch it from broadcast receiver

I want to hide my app from the list of applications so a third person will not know that this app is installed.

I saw that this can be achieved by : If you want to hide your application from Application Launcher, then just do not include android.intent.category.LAUNCHER in any of your activities.

I tried this and it is working . Now i need to define a shortcut to launch my app.

I am trying to achieve this by a broadcast receiver for outgoing call . SO i will check in my onreceive if the number dialed = my pattern then launch my activity

I have some questions here

  1. Is this the right way of doing it

  2. Please see my code below for receiver, here my receiver get called, but along with that system app to handle "number dial" is also called. So even if I dial my pattern, after showing my activity, it makes the call. I want to stop making call if the number dialed matches my pattern. How can I achieve this

  3. I am launching my activity as a new task. When I run my app for the first time, my activity screen is coming. But when i dial again, its not brought to front. How can I achieve this. I think if I solve my previous question, this will be taken care.

     public class OutgoingCallInterceptor extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { final String originalNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); this.setResultData("0123456789"); final String newNumber = this.getResultData(); String msg = "Intercepted outgoing call. Old number " + originalNumber + ", new number " + newNumber; Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); Intent intent1 = new Intent(context,ShowMessageActivity.class); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent1); } }

Menifest File

<application android:icon="@drawable/icon" android:label="Outgoing Call Interceptor">

    <receiver android:name="OutgoingCallInterceptor">
        <intent-filter android:priority="1">
            <action android:name="android.intent.action.NEW_OUTGOING_CALL"></action>
        </intent-filter>
    </receiver>
    <activity android:name="ShowMessageActivity" ></activity>

</application>

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>

But if by list of apps you mean to say all installed apps then I guess that is not possible you can use

<action android:name="android.intent.action.CREATE_SHORTCUT" />

to create shortcut

And for rest of your requirements cant be acheived as I havent found a way to hide my app this way and besides cellphones are personal devices.And you can use a broadcast reciever to know when dialer intent is launched.But again I guess you cannot get the key typed as its all together a different app.

  1. It isn't a right, but maybe the only way to do that :)
  2. You can try to call this.abortBroadcast() on your receiver to abort call. Unfortunately I can't check it now, but it should be working.
public class OpenApplication extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    String compare_num = "777";
    if (number.equals(compare_num)) {
        Intent myintent = new Intent(context, MainActivity.class);
        myintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(myintent);
    //  abortBroadcast();
        setResultData(null);
    }
}

}

   <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

   <!-- OPEN APP -->
    <receiver android:name="receiver.OpenApplication" >
        <intent-filter android:priority="0" >
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
    </receiver>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM