Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App successfully register but not getting in on dialpad in latest version like Oreo and P #12

Open
anujvats111 opened this issue Jul 14, 2018 · 4 comments

Comments

@anujvats111
Copy link

Hello guys,

I have csipsimple code that's working good in eclipse, but i got a issue since some days. The app is successfully register but not goes on dialpad in new version android phone Oreo and P version like one plus and samsung s9. Anybody have any suggestion or solution for this issue. Please help me.

@asceder
Copy link

asceder commented Aug 24, 2018

New Android runtime permission

@anujvats111
Copy link
Author

Hey ,

Asceder, Thanks for replying ...
Could you please explain little bit about New Android runtime permission where i can give ?

@anujvats111
Copy link
Author

Here is my Runtime Permission Activity

public class RuntimePermissionsActivity extends Activity {

public static final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;
private static int SPLASH_TIME_OUT = 11000;
private String TAG = "tag";
public SharedPreferences app_preferences;
public SharedPreferences.Editor editor;
Boolean isFirstTime;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_runtime_permissions);

    app_preferences = PreferenceManager.getDefaultSharedPreferences(RuntimePermissionsActivity.this);
    editor = app_preferences.edit();
    isFirstTime = app_preferences.getBoolean("isFirstTime", true);

    if (isFirstTime) {

        if (checkForPermission()) {
            askForPermissions();
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    editor.putBoolean("isFirstTime", false);
                    editor.commit();
                    Intent i = new Intent(RuntimePermissionsActivity.this, SipHome.class);
                    startActivity(i);
                    finish();

                }
            }, SPLASH_TIME_OUT);
        }
    }
    else
    {
        Intent i = new Intent(RuntimePermissionsActivity.this, SipHome.class);
        startActivity(i);
        finish();
    }
}
void askForPermissions(){

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.READ_CONTACTS)!= PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.CAMERA)!= PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_CONTACTS, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_PHONE_STATE}, REQUEST_ID_MULTIPLE_PERMISSIONS);
        }
    }
}

boolean checkForPermission(){
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
}

@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    Log.d(TAG, "Permission callback called-------");
    switch (requestCode) {
        case REQUEST_ID_MULTIPLE_PERMISSIONS: {

            Map<String, Integer> perms = new HashMap<>();
            // Initialize the map with both permissions
            perms.put(Manifest.permission.CAMERA, PackageManager.PERMISSION_GRANTED);
            perms.put(Manifest.permission.WRITE_EXTERNAL_STORAGE, PackageManager.PERMISSION_GRANTED);
            perms.put(Manifest.permission.ACCESS_FINE_LOCATION, PackageManager.PERMISSION_GRANTED);
            perms.put(Manifest.permission.RECORD_AUDIO, PackageManager.PERMISSION_GRANTED);
            perms.put(Manifest.permission.READ_PHONE_STATE, PackageManager.PERMISSION_GRANTED);
            // Fill with actual results from user
            if (grantResults.length > 0) {
                for (int i = 0; i < permissions.length; i++)
                    perms.put(permissions[i], grantResults[i]);
                // Check for both permissions
                if (perms.get(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
                        && perms.get(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
                        && perms.get(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                        && perms.get(Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
                        && perms.get(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED){
                    Log.d(TAG, "sms & location services permission granted");

                } else {
                    Log.d(TAG, "Some permissions are not granted ask again ");
                    //permission is denied (this is the first time, when "never ask again" is not checked) so ask again explaining the usage of permission

                }
            }
        }
    }

}

}

@rickyManalo
Copy link

anujvats111 how do you apply the permission request on csip? How do you include the activity inside manifest? I really need it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants