当前位置: 首页>>代码示例>>Java>>正文


Java Settings类代码示例

本文整理汇总了Java中android.provider.Settings的典型用法代码示例。如果您正苦于以下问题:Java Settings类的具体用法?Java Settings怎么用?Java Settings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Settings类属于android.provider包,在下文中一共展示了Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.provider.Settings; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = getIntent();
    int button = intent.getIntExtra(BUTTON_KEY, 0);
    if(button > 0) {
        ((TextView)findViewById(R.id.textview)).setText("Button " + button + " is pressed!");
    }

    //Ask permission
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {

        Intent permissionIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                Uri.parse("package:" + getPackageName()));
        startActivityForResult(permissionIntent, CODE_DRAW_OVER_OTHER_APP_PERMISSION);
    }
}
 
开发者ID:gokhanoguz,项目名称:FloatingWidget,代码行数:20,代码来源:MainActivity.java

示例2: getDeviceId

import android.provider.Settings; //导入依赖的package包/类
public static String getDeviceId(Context context) {
    String androidId = Settings.Secure.getString(context.getContentResolver(),
            Settings.Secure.ANDROID_ID);
    if (!TextUtils.isEmpty(androidId)) {
        String serial = Build.SERIAL;
        if (!"unknown".equalsIgnoreCase(serial)) {
            return androidId + serial;
        }
        return androidId;
    }

    File file = new File(context.getFilesDir(), "deviceId");
    file.mkdir();
    File[] files = file.listFiles();
    if (files.length > 0) {
        return files[0].getName();
    }
    String id = UUID.randomUUID().toString();
    (new File(file, id)).mkdir();
    return id;
}
 
开发者ID:homeii,项目名称:GxIconAndroid,代码行数:22,代码来源:ExtraUtil.java

示例3: goToInstalledAppDetails

import android.provider.Settings; //导入依赖的package包/类
/**
 * 打开已安装应用的详情
 */
public static void goToInstalledAppDetails(Context context, String packageName) {
    Intent intent = new Intent();
    int sdkVersion = Build.VERSION.SDK_INT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.fromParts("package", packageName, null));
    } else {
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        intent.putExtra((sdkVersion == Build.VERSION_CODES.FROYO ? "pkg"
                : "com.android.settings.ApplicationPkgName"), packageName);
    }
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:19,代码来源:PackageUtil.java

示例4: onPreferenceChange

import android.provider.Settings; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
  String value = (String)newValue;

  final Uri uri;

  if (Settings.System.DEFAULT_NOTIFICATION_URI.toString().equals(value)) {
    uri = null;
  } else {
    uri = Uri.parse(value);
  }

  recipients.setRingtone(uri);

  new AsyncTask<Uri, Void, Void>() {
    @Override
    protected Void doInBackground(Uri... params) {
      DatabaseFactory.getRecipientPreferenceDatabase(getActivity())
                     .setRingtone(recipients, params[0]);
      return null;
    }
  }.execute(uri);

  return false;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:26,代码来源:RecipientPreferenceActivity.java

示例5: handleClick

import android.provider.Settings; //导入依赖的package包/类
@Override
public void handleClick() {
    if (mMode != GravityBoxSettings.ED_DISABLED) {
        collapsePanels();
        // give panels chance to collapse before changing expanded desktop state
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Settings.Global.putInt(mContext.getContentResolver(),
                        ModExpandedDesktop.SETTING_EXPANDED_DESKTOP_STATE,
                        (mExpanded ? 0 : 1));
            }
        }, 800);
    }
    super.handleClick();
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:17,代码来源:ExpandedDesktopTile.java

示例6: refreshLastRescanAction

import android.provider.Settings; //导入依赖的package包/类
private void refreshLastRescanAction() {
    String message;
    boolean clickable = false;
    switch (NetworkAutoRefresh.getLastError(getActivity())){
        case  NetworkAutoRefresh.AUTO_RESCAN_ERROR_NO_WIFI:
            message = getString(R.string.rescan_error_wifi);
            int wifiPolicy = Settings.System.getInt(getActivity().getContentResolver(),
                    Settings.Global.WIFI_SLEEP_POLICY,
                    Settings.Global.WIFI_SLEEP_POLICY_NEVER);
            if(wifiPolicy!=Settings.Global.WIFI_SLEEP_POLICY_NEVER&&wifiPolicy!=Settings.Global.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED) {
                message += " (" + getString(R.string.rescan_error_wifi_click_for_more_info) + ")";
                clickable = true;
            }

            break;
        case NetworkAutoRefresh.AUTO_RESCAN_ERROR_UNABLE_TO_REACH_HOST:
            message = getString(R.string.rescan_error_server);
            break;
        default:
            message = getTimeFormat(PreferenceManager.getDefaultSharedPreferences(getActivity()).getLong(NetworkAutoRefresh.AUTO_RESCAN_LAST_SCAN, 0));
    }
    getActionById(LAST_RESCAN_ID).setLabel2(message);
    getActionById(LAST_RESCAN_ID).setEnabled(clickable);
    if(getGuidedActionsStylist().getActionsGridView()!=null&&getGuidedActionsStylist()!=null) //depending on when it is called
        getGuidedActionsStylist().getActionsGridView().getAdapter().notifyDataSetChanged();
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:27,代码来源:RescanFragment.java

示例7: updateBacklightTime

import android.provider.Settings; //导入依赖的package包/类
public void updateBacklightTime(int time)
   {    	
       ContentValues values = new ContentValues(1);
       ContentResolver cr = mcontext.getContentResolver();
       Uri blTimeUri = Settings.System.CONTENT_URI;
       int result;

       //Log.v("updateBacklightTime", "num:" + time);
       Settings.System.putInt(cr, Settings.System.SCREEN_OFF_TIMEOUT, time);
//  Log.v("updateBacklightTime", "putINTOK");

       values.put("screen_off_timeout", time); 

       try
{
    result = cr.update(blTimeUri, values, null, null);
       }
catch (Exception e)
{
    result = 0;
       }  
//   Log.v("Result", "result is:" + result);      	
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:24,代码来源:EnergyWrapper.java

示例8: startDialPhoneNumber

import android.provider.Settings; //导入依赖的package包/类
@Override
public void startDialPhoneNumber(String number) {
    Intent phoneIntent = new Intent(Intent.ACTION_DIAL, Uri.fromParts(
            "tel", number, null));
    if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
        if (((TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE))
                .getSimState() == TelephonyManager.SIM_STATE_READY) {
            if (Settings.Global.getInt(getContext().getContentResolver(),
                    Settings.Global.AIRPLANE_MODE_ON, 0) == 0) {
                startActivity(phoneIntent);
                return;
            }
        }
    }
    Snackbar.make(phoneTextView, R.string.calls_unavailable_error, Snackbar.LENGTH_SHORT).show();
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:17,代码来源:UserInfoFragment.java

示例9: doGetId

import android.provider.Settings; //导入依赖的package包/类
private static long doGetId(Application application) {
    String androidId = Settings.Secure.getString(application.getContentResolver(),
            Settings.Secure.ANDROID_ID);
    if (TextUtils.isEmpty(androidId) || "9774d56d682e549c".equals(androidId)) {
        androidId = PreferencesUtils.getPreferences(application)
                .getString(Settings.Secure.ANDROID_ID, "0");
    }
    long breventId;
    try {
        breventId = new BigInteger(androidId, 16).longValue();
    } catch (NumberFormatException e) {
        breventId = 0;
        UILog.w("Can't parse " + androidId, e);
    }
    if (breventId == 0) {
        breventId = 0xdeadbeef00000000L | new SecureRandom().nextInt();
        PreferencesUtils.getPreferences(application).edit()
                .putString(Settings.Secure.ANDROID_ID, Long.toHexString(breventId)).apply();
    }
    return breventId;
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:22,代码来源:BreventApplication.java

示例10: showInstalledAppDetails

import android.provider.Settings; //导入依赖的package包/类
/**
     * app 设置
     *
     * @param context     c
     * @param packageName pn
     */
    public static void showInstalledAppDetails(Context context, String packageName) {
        Intent intent = new Intent();
        final int apiLevel = Build.VERSION.SDK_INT;
        if (apiLevel >= 9) { // 2.3(ApiLevel 9)以上,使用SDK提供的接口
            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            Uri uri = Uri.fromParts(SCHEME, packageName, null);
            intent.setData(uri);
        } else { // 2.3以下,使用非公开的接口(查看InstalledAppDetails源码)
// 2.2和2.1中,InstalledAppDetails使用的APP_PKG_NAME不同。
            final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22
                    : APP_PKG_NAME_21);
            intent.setAction(Intent.ACTION_VIEW);
            intent.setClassName(APP_DETAILS_PACKAGE_NAME,
                    APP_DETAILS_CLASS_NAME);
            intent.putExtra(appPkgName, packageName);
        }
        context.startActivity(intent);
    }
 
开发者ID:abook23,项目名称:godlibrary,代码行数:25,代码来源:AndroidUtils.java

示例11: getSettingsIntent

import android.provider.Settings; //导入依赖的package包/类
@NonNull private Intent getSettingsIntent(String packageName) {
  Intent intent = new Intent();
  intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  Uri uri = Uri.fromParts("package", packageName, null);
  intent.setData(uri);
  return intent;
}
 
开发者ID:Arjun-sna,项目名称:android-permission-checker-app,代码行数:8,代码来源:AppDetailsFragment.java

示例12: Recarregar

import android.provider.Settings; //导入依赖的package包/类
private void Recarregar() {
    //Verifica se há internet
    if (Utils.haveInternet(getActivity())) {
        //Carrega as Notícias
        new DownloadNoticias(getActivity(), mRelativeLayout, mRecyclerView).execute(Utils.getUrlApiNoticia(getActivity()));
    } else
        SnackbarManager.show(
                Snackbar.with(getActivity())
                        .text("Por favor verifique sua conexão com a Internet")
                        .type(SnackbarType.MULTI_LINE)
                        .actionLabel("CONECTAR")
                        .actionColor(getResources().getColor(R.color.colorAccent))
                        .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
                        .actionListener(new ActionClickListener() {
                            @Override
                            public void onActionClicked(Snackbar snackbar) {
                                //Inicia as configurações de rede
                                startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                            }
                        })
        );
}
 
开发者ID:alessandrojean,项目名称:order-by-android,代码行数:23,代码来源:NoticiasLista.java

示例13: onDestroy

import android.provider.Settings; //导入依赖的package包/类
@Override
public void onDestroy() {
    if (created) {
        this.unregisterReceiver(batReceiver);
        Log.d(getClass().getSimpleName(), "Receiver unregistered");
        if (wl.isHeld()) {
            wl.release();
            Log.d(getClass().getSimpleName(), "WL released");
        }
    }

    boolean isEnabled = Settings.System.getInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1;
    if (isEnabled) {
        Log.d(getClass().getSimpleName(), "Turning airplanemode off");
        Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0);
        Intent reload = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        reload.putExtra("state", false);
        sendBroadcast(reload);
    }

    Log.d(getClass().getSimpleName(), "Charge Preserver service stopped");
    Toast.makeText(this.getApplicationContext(), "Service has been shutdown", Toast.LENGTH_SHORT).show();
    prefEditor.putBoolean("isService", false);
    prefEditor.commit();
}
 
开发者ID:d4rken,项目名称:chargepreserver,代码行数:26,代码来源:CPService.java

示例14: getDeviceId

import android.provider.Settings; //导入依赖的package包/类
public static String getDeviceId(Context context) {
    TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = tm.getDeviceId();
    String tmDevice;
    if(null != imei && !"".equals(imei)) {
        tmDevice = "^[0]+$";
        if(!imei.matches(tmDevice)) {
            return imei;
        }
    }

    tmDevice = "" + tm.getDeviceId();
    String tmSerial = "" + tm.getSimSerialNumber();
    String androidId = "" + Settings.Secure.getString(context.getContentResolver(), "android_id");
    return (new UUID((long)androidId.hashCode(), (long)tmDevice.hashCode() << 32 | (long)tmSerial.hashCode())).toString();
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:17,代码来源:MDevice.java

示例15: onCreate

import android.provider.Settings; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    context = this;
    twitter = TwitterUtil.getTwitterInstance(this);
    
    super.onCreate(savedInstanceState);
    setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
    
    SettingsFragment fragment = new SettingsFragment();
    getFragmentManager().beginTransaction()
                        .replace(android.R.id.content, fragment)
                        .commit();

    if (!NotificationService.isNotificationAccessEnabled) {
        startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
    }
}
 
开发者ID:Siketyan,项目名称:SilicaGel,代码行数:18,代码来源:SettingsActivity.java


注:本文中的android.provider.Settings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。