0

I have an android app that needs to hide and only appear when the user dials a specific number. Can I please know exactly how it is done? I have searched and no success. Thanks in advance.

Avi Kumar
  • 4,403
  • 8
  • 36
  • 67
Rana Shouman
  • 106
  • 9
  • This has been asked before: http://stackoverflow.com/questions/10860369/fetch-dial-number-while-calling. – wojciii Aug 03 '12 at 11:53
  • ok I was able to hide the app and then launch it by the dialpad, but after i launch it the icon shows again. – Rana Shouman Aug 06 '12 at 09:31

1 Answers1

1

In order to hide the app completely from the launcher, you need first to create a BroadcastReciever:

   public class LaunchAppViaDialReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Bundle bundle = intent.getExtras();
    if (null == bundle)
        return;
    String phoneNubmer = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    //here change the number to your desired number
    if (phoneNubmer.equals("<Requested Number>")) {
        setResultData(null);
        if(status == true){
            PackageManager packageManager = context.getPackageManager();
            ComponentName componentName = new ComponentName(context,
                    YourLauncherActivity.class);
            packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                    PackageManager.DONT_KILL_APP);
            Intent appIntent = new Intent(context,    YourLauncherActivity.class);
            appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(appIntent);
        }
    }
}

And add the Permission: android.permission.PROCESS_OUTGOING_CALLS Add the BroadcastReciever to the Manifest File.

It is Preferable to make the user set the Ghost mode via preferences

Rana Shouman
  • 106
  • 9