简体   繁体   中英

Android Hidden App start from dialer

We can hide the android app from launcher by editing manifest XML,but is there any code snippet or example by which we can hide the app and start it by entering some code like # #4444# # like that.Any way to do this?? Thanks in advance.

To start your app from dialer you need to do three things:
1. Add receiver to your AdroidManifest.xml

 <receiver android:name="com.example.HiddedReceiver">
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
        </intent-filter>
    </receiver>

2. Create BroadcastReceiver as stated in xml. It will intercept EVERY calls number. You just need to scan it for your string and do apropiate action - in this case fire off an intent.

public class HiddenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(android.intent.action.NEW_OUTGOING_CALL)) {
        String resultData = getResultData();
        if (resultData != null) {
            if (resultData.contains("YOURCODE")) {
                setResultData(null); // it wont continue calling that number

                //HERE CREATE your intent

                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        }
    }
}    
}

3. To get this working, you need to tell android you will be using this feature, and to grant permission to process calls from the user at install time.

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

i didnt test it, but this one works like a charm:

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

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