Android. Launch app from Dialer

后端 未结 4 857
借酒劲吻你
借酒劲吻你 2020-12-16 04:32

This is what I have so far but nothing happens when I input this combination in dialer

public class DialReceiver extends BroadcastReceiver
{
    @Override
           


        
4条回答
  •  情话喂你
    2020-12-16 05:26

    Try This,

    Add to this in manifest, here host is 12456, so your secret code is *#*#123456#*#* (dial-in dialped)

     //here is your broadcast receiver class
            
                
                
            
        
    

    here is your Broadcast Receiver class :

     class Dialer : BroadcastReceiver() {
    
        override fun onReceive(context: Context?, intent: Intent?) {
             // Declare Here your launcher activity in Intent
            var  i : Intent = Intent(context, MainActivity::class.java)  
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context!!.startActivity(i);
        }
    }
    

提交回复
热议问题