Launching an Android Application from the Browser

前端 未结 2 640
抹茶落季
抹茶落季 2020-11-30 06:36

I have looked at several Stack Overflow questions with similar titles to mine. Each is answered, and the original author seems satisfied, but when I try to replicate their r

2条回答
  •  醉梦人生
    2020-11-30 06:59

    Try this, if you want to start your application from browser I've done this yesterday

    1) On localhost make the html page

    
    
    
    
    Test link
    
    
    

    2) make a class

       import org.xml.sax.Parser;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.TextView;
    
    public class URLHandler extends Activity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
    
    
        TextView uri=(TextView)findViewById(R.id.uri);
        TextView uri2=(TextView)findViewById(R.id.uri);
    
    
        if (Intent.ACTION_MAIN.equals(getIntent().getAction())) {
          String intentUri=(new Intent("yourownscheme://example.com/")).toUri(Intent.URI_INTENT_SCHEME).toString();
    
    
    
          uri.setText(intentUri);
    
        }
       }
      }
    

    3) The manifest is below

    
    
    
      
      
    
    
    
          
            
    
                
    
                
                
                
            
        
    
    
      
    
    

    4) When you installed you'r application on emulator, open browser and go to localhost tap the link and your application, if it's installed gonna launch, othervice it would be error

提交回复
热议问题