繁体   English   中英

uid 10058没有android.permission.SEND_SMS

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM