标签: android-6.0-marshmallow

要求READ_SMS要求"发送和查看SMS消息"

我的应用只需要使用"READ_SMS"权限.我的问题是在Android 6.0上当我需要使用新的权限系统时,它会向用户询问"发送和查看SMS消息".

这是我的代码:

ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_SMS}, READ_SMS_PERMISION_REQ);
Run Code Online (Sandbox Code Playgroud)

到底是怎么回事?谢谢!

permissions sms android android-6.0-marshmallow

4
推荐指数
1
解决办法
2366
查看次数

为什么这个代码不适用于android 6 marshmallow Api 23?

为什么这个代码不适用于android 6 marshmallow Api 23?它不会抛出异常,但callStateListener中的代码不起作用.

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener callStateListener = new PhoneStateListener() {
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        //if(logAtive) Log.i(LOG_TAG,incomingNumber + " " + state);
        if(state==TelephonyManager.CALL_STATE_RINGING){
            Toast.makeText(getApplicationContext(),"Hey, receive your call. Phone is ringing.",
                    Toast.LENGTH_LONG).show();
        }
        if(state==TelephonyManager.CALL_STATE_OFFHOOK){
            Toast.makeText(getApplicationContext(),"You are in a call. ",
                    Toast.LENGTH_LONG).show();
        }
        if(state==TelephonyManager.CALL_STATE_IDLE){
            Toast.makeText(getApplicationContext(),"You are in idle state… ",
                    Toast.LENGTH_LONG).show();
        }
    }
};

telephonyManager.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);
Run Code Online (Sandbox Code Playgroud)

权限:

<uses-feature android:name="android.hardware.telephony" android:required="true" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_INCOMING_CALLS" /> …
Run Code Online (Sandbox Code Playgroud)

android telephonymanager android-6.0-marshmallow

4
推荐指数
1
解决办法
1万
查看次数

Android M快捷方式安装/卸载重复

我试图通过服务为我的应用程序创建一个快捷方式.以下代码正在处理SDK <= 21,但它无法正常工作SDK = 23

快捷方式的创建方式是这样完成的:

        Intent shortcutIntent = new Intent(this, MainActivity.class);
        shortcutIntent.putExtra(EXTRA_SHORTCUT_CLICKED, true); //This is only to check when the user clicked on the created shortcut
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

        Intent addIntent = new Intent();
        addIntent.putExtra("duplicate", false);
        addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "TEST");
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.application_icon));
        addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);

        sendBroadcast(addIntent);
Run Code Online (Sandbox Code Playgroud)

SDK <= 21创建快捷方式中,如果已存在,则不会创建其他实例.

SDK = 23快捷方式将仅如果我按创建shorcut并再次尝试创建快捷方式.如果我重新启动该设备,然后再次尝试创建快捷方式复制或.

我尝试先卸载快捷方式,但没有成功SDK 23,如下所示:

        Intent shortcutIntent = new Intent(this, MainActivity.class);
        shortcutIntent.putExtra(EXTRA_SHORTCUT_CLICKED, true); //This is only to check when the user clicked …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-6.0-marshmallow

4
推荐指数
1
解决办法
1448
查看次数

在android API级别23中不推荐使用SmsMessage.createFromPdu

我正在尝试使用以下代码阅读收到的短信,它在API级别23下工作,但在API级别23 createFromPdu方法已弃用.在谷歌文档中它有一个替代方法,但我如何使用它.

public class IncomingSms extends BroadcastReceiver {

// Get the object of SmsManager
final SmsManager sms = SmsManager.getDefault();

public void onReceive(Context context, Intent intent) {

    // Retrieves a map of extended data from the intent.
    final Bundle bundle = intent.getExtras();

    try {

        if (bundle != null) {

            final Object[] pdusObj = (Object[]) bundle.get("pdus");

            for (int i = 0; i < pdusObj.length; i++) {

                SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
                String phoneNumber = currentMessage.getDisplayOriginatingAddress();

                String senderNum = phoneNumber; …
Run Code Online (Sandbox Code Playgroud)

android android-sdk-tools smsmanager android-studio android-6.0-marshmallow

4
推荐指数
3
解决办法
1万
查看次数

Android 6.0蓝牙程序无法发现任何可用的蓝牙设备

目标

发现所有可用的蓝牙设备,例如我的iPad蓝牙ON(可发现).

ANDROID VERSION

6

问题

无法发现任何蓝牙设备.

// Permission
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

public BroadcastReceiver mReceiver;
public IntentFilter filter;

private boolean discover_AvailableBluetoothDevice() {
        mReceiver = new BroadcastReceiver() {
            public void onReceive(Context context, Intent intent) {
                Log.d(TAG, "onReceive Called");
                String action = intent.getAction();
                // When discovery finds a device
                if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
                    Log.d(TAG, "ACTION_DISCOVERY_STARTED");
                } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
                    Log.d(TAG, "ACTION_DISCOVERY_FINISHED");
                } else if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                    Log.d(TAG, "ACTION_FOUND");
                    // Get the BluetoothDevice object from the Intent
                    BluetoothDevice device …
Run Code Online (Sandbox Code Playgroud)

android bluetooth android-permissions android-6.0-marshmallow

4
推荐指数
1
解决办法
2256
查看次数

清除Android M上允许的权限

如何清除Android Marshmallow上所有允许的权限?这需要开发和测试.

我知道,我可以手动完成,但我想以编程方式执行此操作.

android android-permissions android-6.0-marshmallow

4
推荐指数
1
解决办法
1776
查看次数

启动时的运行时权限

我有一个需要CAMERA和WRITE_SETTINGS权限的手电筒,我需要先处理这些权限,我已经知道如何做到这一点,那么如果是理所当然的,例如,开始我的主要活动......(对不起,我在新安卓)

android android-6.0-marshmallow runtime-permissions

4
推荐指数
1
解决办法
2076
查看次数

Android Marshmallow - 从另一个库模块调用库模块(本机库)崩溃

我的应用程序中有3个模块,名为(例如)"app","emp-library","face-library".

app - 仅包含加载屏幕并打开emp-library库活动.

emp-library - 它是Library模块,它包含用于获取员工图像的基本员工表单和相机模块,并且图像将被传递到face-library以检测面部.

face-library - 它是Library模块,它包含用于检测面部的面部检测库(Native library - 自己的面部检测算法)

该应用程序正在Lollipop设备中运行.但是当我在Marshmallow中执行应用程序时,它会因以下异常而崩溃.

Fatal signal 11 (SIGSEGV), code 2, fault addr 0xdeadbaad in tid 32696
Run Code Online (Sandbox Code Playgroud)

注意:这是我在日志中收到的唯一错误消息.

我是否想要为Marshmallow设备构建任何特定的本机库?请有人帮我解决这个问题吗?

更新:

- >因为我无法找到任何技术错误(据我所知,我没有在本机代码中得到任何异常)我遵循了试错法.

- >我已经从app模块添加了face-library本机调用(在我的情况下我不应该使用它).现在应用程序没有崩溃.

- >所以,问题是" 来自emp-library模块的face-library模块调用".两者都是库模块.

Marshmallow中是否存在从库(emp-library)模块调用本机库(face-library)的约束?

android fatal-error opencv4android android-5.0-lollipop android-6.0-marshmallow

4
推荐指数
1
解决办法
188
查看次数

如果用户第一次拒绝,如何再次询问权限(RunTime)

我想在这种情况下再次向用户询问是否允许他/她首次拒绝。我已经设置了权限,但是即使按拒绝选项,我的应用程序仍可以运行。我有一个应该执行我想做的事情的代码,但是当我按Alt + Enter时,我得到了不能解析符号Snackbar的代码,它创建了另一个活动,剩余的-make-permision_available_camera出现红色错误。

@Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
            @NonNull int[] grantResults) {

        if (requestCode == REQUEST_CAMERA) {
            // BEGIN_INCLUDE(permission_result)
            // Received permission result for camera permission.
            Log.i(TAG, "Received response for Camera permission request.");

            // Check if the only required permission has been granted
            if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                // Camera permission has been granted, preview can be displayed
                Log.i(TAG, "CAMERA permission has now been granted. …
Run Code Online (Sandbox Code Playgroud)

android android-permissions android-6.0-marshmallow runtime-permissions

4
推荐指数
1
解决办法
6585
查看次数

DatePickerDialog标头背景色

我为DatePickerDialog背景设置了一种样式,它在Nexus 5(棉花糖)上的显示方式有所不同:

在此处输入图片说明

我使用的样式是:

<style name="datepicker">
    <item name="android:background">@color/android:white</item>
    <item name="android:textColorPrimaryInverse">@color/android:black</item>
    <item name="android:textColorPrimary">@color/android:black</item>
    <item name="android:textColorSecondary">@color/colorAccent</item>
    <item name="android:textColorSecondaryInverse">@color/colorAccent</item>
    <item name="android:textColorTertiary">@color/android:black</item>
</style>
Run Code Online (Sandbox Code Playgroud)

colorAccent是金)

最上面的年份应该由所控制textColorSecondary,但现在却显示为黑色。标头的背景是灰色,我想要白色。这些棉花糖的物品叫什么名字?

android android-6.0-marshmallow

4
推荐指数
1
解决办法
1890
查看次数