I am an android developer. (beginner)
And I want to know how can I make my application launch by entering/calling a specific code number (from the same device), such as smart lock application, you can launch it by calling this code #000.
You have to use Broadcast Receiver...
public class OutgoingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if(null == bundle)
return;
String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.i("OutgoingCallReceiver",phonenumber);
Log.i("OutgoingCallReceiver",bundle.toString());
if(code.equals("#000") {
intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity"));
And Your Android Manifest
<receiver android:name="com.varma.samples.detectcalls.receivers.OutgoingCallReceiver">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter>
</receiver>
You can launch application by it's full package name How to start activity in another application?. You can implement desired logic inside your app-launcher. like bind a code #000 to a specific package like "com.example.android".
if(code.equals("#000") {
intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity"));
}
else if{code.equals(#???"){
//another app
}