tqcenglish / CSipSimple

CSipSimple For Android Studio
103 stars 96 forks source link

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

Open anujvats111 opened 6 years ago

anujvats111 commented 6 years ago

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 commented 6 years ago

New Android runtime permission

anujvats111 commented 6 years ago

Hey ,

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

anujvats111 commented 6 years ago

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 commented 5 years ago

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