我怎能不让屏幕闪烁?

时间:2013-05-15 02:20:20

标签: android

我在我的真实手机中安装了以下应用程序,我希望当我点击应用程序图标时会显示一条信息。 但我发现手机屏幕闪烁,似乎系统创建并显示UI,然后快速移植到目标UI。 我不希望屏幕闪烁,我该怎么办?谢谢!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidbook.telephony" android:versionCode="1"
    android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".TelephonyDemo" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="4" />
    <uses-permission android:name="android.permission.SEND_SMS"/>
</manifest> 


package com.androidbook.telephony;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Toast;

public class TelephonyDemo extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        doSend(null);
    }
    public void doSend(View view) {

        try {
            sendSmsMessage(
                "12345678","Hello");
            Toast.makeText(this, "SMS Sent", 
                    Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            Toast.makeText(this, "Failed to send SMS", 
                    Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    private void sendSmsMessage(String address,String message)throws Exception
    {
        SmsManager smsMgr = SmsManager.getDefault();
        smsMgr.sendTextMessage(address, null, message, null, null);
        finish();
    }
}

1 个答案:

答案 0 :(得分:0)

它的闪烁,因为默认情况下,一个Activity有一个UI,它的绘图是你的(因为你没有设置任何,它使用纯白色或纯黑色)。将android:theme =“@ android:style / Theme.NoDisplay”添加到您的清单中,这样它就不会尝试绘制任何东西