I happen to have a mobile-friendly web app, but my users desperately want to install it to their app drawer :/ I have some experience with Java, the new Android Studio, and I see some instructions on this stackoverflow question, but I'm unsure where this code belongs:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
Putting it in the onCreate
method of the default action yields errors that suggest that's the wrong place for an intent. Where would be a good place to execute such an intent?
For Your reference, i tried this code,
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.com"));
startActivity(browserIntent);
}
}
In Manifest's xml (e.g. AndroidManifest.xml
) add
<uses-permission android:name="android.permission.INTERNET"/>
Example:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="...">
<uses-permission android:name="android.permission.INTERNET" />
<application ...>
...
</application>
</manifest>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With