package com.android.action.activity;


import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;


class NS{

    public static void GotoNS(Context context){
        Intent intent = new Intent();
        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O) {
            intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
            intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
        }
        else if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP&&
                Build.VERSION.SDK_INT<Build.VERSION_CODES.O) {
            intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
            intent.putExtra("app_package", context.getPackageName());
            //Log.e("success grt packagename",context.getPackageName());
            intent.putExtra("app_uid", context.getApplicationInfo().uid);
            //Log.e("success get uid", String.valueOf(context.getApplicationInfo().uid));
        }
        else if(Build.VERSION.SDK_INT==Build.VERSION_CODES.KITKAT) {
            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            intent.setData(Uri.parse("package:" + context.getPackageName()));
        }
        else{
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            if(Build.VERSION.SDK_INT>=9)
            {
                intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                intent.setData(Uri.fromParts("package",context.getPackageName(),null));
            }
            else if(Build.VERSION.SDK_INT<=8){
                intent.setAction(Intent.ACTION_VIEW);
                intent.setClassName("com.android.settings", "com.android.setting.InstalledAppDetails");
                intent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
            }
        }
        context.startActivity(intent);
    }
    
}
