Android : launch hidden app when secret code is dialed

on Wednesday, January 28, 2015


my requirement is to launch an hidden app when a secret code is dailed.


MainActivity.java



public class MainActivity extends
BroadcastReceiver {

String dialed_number;

@Override
public void onReceive(Context context, Intent intent)
{
dialed_number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

if(dialed_number.equals("*0*1235#"))
{
Intent appIntent = new Intent(context, MainActivity.class);
appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(appIntent);
setResultData(null);
}
}

}


AndroidManifest.xml



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tuto.bala.helloworld" >
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<receiver
android:name=".MainActivity">
</receiver>
</application>

</manifest>


When i run the project I get the following exception: connection problem invalid mmi code android


Can anyone please help


Regards, Bala


0 comments:

Post a Comment