应用程序android启动没有图标

时间:2016-04-08 15:26:05

标签: java android

我想在Android中构建一个应用程序,它不会通过单击图标来启动,而是从电话的小键盘中键入#8888#。我阅读并关注this tutorial,但我不知道如何实施课程Launch。你能救我吗?

1 个答案:

答案 0 :(得分:0)

        First Create a DialerReceiver extends BroadcastReceiver    

        import android.content.BroadcastReceiver;
        import android.content.Context;
        import android.content.Intent;
        import android.util.Log;

        public class DialerReceiver extends BroadcastReceiver {


            String dialedno;

            @Override
            public void onReceive(Context arg0, Intent arg1) {
                // TODO Auto-generated method stub      

                 dialedno=arg1.getStringExtra(Intent.EXTRA_PHONE_NUMBER);


                if(dialedno.equals("##8888##"))
                {
                    Intent callConnekt=new Intent(arg0, YourActivity.class);
                    callConnekt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    arg0.startActivity(callConnekt);

                    setResultData(null);//To Close USSD Dialing
                }

            }       

         } 

        Register the DialerReceiver inside Manifest file

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


        <receiver android:name="DialerReceiver" android:exported="true" android:enabled="true" >
                <intent-filter>
                    <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
                </intent-filter>
            </receiver>

If you don't want show App icon in Launcher then remove below line

<category android:name="android.intent.category.LAUNCHER" />