我在我的真实手机中安装了以下应用程序,我希望点击应用程序图标时显示信息。但是我发现手机屏幕闪烁,似乎系统创建并显示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();
}
}