简体   繁体   English

我对应用程序的要求如何拨打和管理电话?

[英]How i do to my app asks to make and manage phone calls?

My app need the user accept's the "Allow to make and manage phone calls" Pop up. 我的应用程序需要用户接受的“允许拨打和管理电话”弹出窗口。 How i make these pop up in the first time the application starts? 我如何在应用程序首次启动时弹出这些窗口?

I already added the permission in the manifest : 我已经在清单中添加了权限:

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

But nothing from the pop up. 但是没有弹出。

From Android 6.0 you must to provide runtime permissions link . 从Android 6.0开始,您必须提供运行时权限链接

public  boolean isPermissionGranted() {
    if (Build.VERSION.SDK_INT >= 23) {
        if (checkSelfPermission(android.Manifest.permission.CALL_PHONE)
                == PackageManager.PERMISSION_GRANTED) {
            Log.v("TAG","Permission is granted");
            return true;
        } else {

            Log.v("TAG","Permission is revoked");
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, 1);
            return false;
        }
    }
    else { //permission is automatically granted on sdk<23 upon installation
        Log.v("TAG","Permission is granted");
        return true;
    }
}


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

        case 1: {

            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Toast.makeText(getApplicationContext(), "Permission granted", Toast.LENGTH_SHORT).show();
                call_action();
            } else {
                Toast.makeText(getApplicationContext(), "Permission denied", Toast.LENGTH_SHORT).show();
            }
            return;
        }

        // other 'case' lines to check for other
        // permissions this app might request
    }
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 分发我的Java应用程序,如何管理目录 - distributing my java app, HOW do I manage directories 我如何做到这一点,以便我的代码不断询问第1、2和3部分以及Choice :? 第三次尝试后,扫描仪将关闭 - How do I make it so my code continuously asks parts 1., 2., and 3. and Choice:? After a third attempt the scanner just closes 如何让 Firebase 电话身份验证适用于我的应用? - How do I get Firebase Phone Authentication to work for my app? 如何管理2个persistense单位并使我的应用识别要使用的单位? - How can I manage to use 2 persistense units and make my app to recognize which to use? 如何让我的应用程序出现在app chooser中? - How do I make my app appear in app chooser? 如何让手机进入睡眠状态? - How Do I Make The Phone Go To Sleep? 如何防止我的Android应用在每次手机进入睡眠状态时重置? - How do I prevent my Android app from resetting every time my phone sleeps? 如何将Ruby脚本与JAR捆绑在一起并对其进行调用 - How do I bundle Ruby Scripts with my JAR and get make calls to them 如何确保我的应用在平板电脑商店中展示 - How do I make sure that my app showing in tablet store 如何让我的Android应用生成随机数? - How do I make my Android app generate a random number?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM