开发者

Android App - disappearance of app GUI

I'm trying to create a simple app, whose main task is to open the browser on defin开发者_如何学运维ed URL. I've created first Activity:

public class MyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.main);

    Intent myIntent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("http://my.url.tld"));
    startActivity(myIntent);
}

Here's my AndroidManifest.xml:

<manifest ...>
    <application ...>
        <activity android:name=".MyActivity" ...>
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

This code is fully functional, but before it opens the browser, it displays a black background - blank app GUI. I didn't figured out, how to go directly do the browser (without displaying the GUI).

Anyone knows?


Add this theme declaration to your activity definition in you manifest

    <activity android:name=".MyActivity" 

      android:theme="@android:style/Theme.Translucent.NoTitleBar"

      >

Be careful with this, you must call finish(); from your activity after you are done with it otherwise users could get stuck with an invisible activity that prevents them from interacting the phonetop.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜