[英]uid 10058 does not have android.permission.SEND_SMS
我收到上述錯誤,無法使用此代碼發送短信,請幫幫我。 我的清單文件是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user8.seminia" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-permission android:name="android.permission.SEND_SMS" />
<activity
android:name=".MainActivity"
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>
我也無法使用許可發送短信,因為我們在發布我的主要活動代碼
EditText name,phone,email;
Button bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
name=(EditText)findViewById(R.id.editText);
phone=(EditText)findViewById(R.id.editText3);
email=(EditText)findViewById(R.id.editText2);
bt=(Button)findViewById(R.id.button);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String user=name.getText().toString();
String num=phone.getText().toString();
String cont=email.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("9350581140", null,"hello", null, null);
Toast.makeText(getApplicationContext(), "SMS sent.",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again."+e.toString(),
Toast.LENGTH_LONG).show();
Log.d("sms",e.toString());
e.printStackTrace();
}
}
});
}
該uses-permission
元素去下manifest
,不是在application
清單中的XML。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.