java类android.preference.PreferenceActivity的实例源码

CommonUtil.java 文件源码 项目:OSMonitor.Legacy 阅读 39 收藏 0 点赞 0 评论 0
public static boolean checkExtraStore(PreferenceActivity activity)
{
    boolean flag = false;
    if(Integer.parseInt(Build.VERSION.SDK) >= 8)
    {
        // use Reflection to avoid errors (for cupcake 1.5)
        Method MethodList[] = activity.getClass().getMethods();
        for(int checkMethod = 0; checkMethod < MethodList.length; checkMethod++)
        {
            if(MethodList[checkMethod].getName().indexOf("ApplicationInfo") != -1)
            {
                try{
                    if((((ApplicationInfo) MethodList[checkMethod].invoke(activity , new Object[]{})).flags & 0x40000 /* ApplicationInfo.FLAG_EXTERNAL_STORAGE*/ ) != 0 )
                        flag = true;
                }
                catch(Exception e) {}
            }
        }
    }
    return flag;
}
TestUtilities.java 文件源码 项目:glassauth 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
CompareFunc.java 文件源码 项目:OSMonitor.Classical 阅读 26 收藏 0 点赞 0 评论 0
public static boolean checkExtraStore(PreferenceActivity activity)
{
    boolean flag = false;
    if(Integer.parseInt(Build.VERSION.SDK) >= 8)
    {
        // use Reflection to avoid errors (for cupcake 1.5)
        Method MethodList[] = activity.getClass().getMethods();
        for(int checkMethod = 0; checkMethod < MethodList.length; checkMethod++)
        {
            if(MethodList[checkMethod].getName().indexOf("ApplicationInfo") != -1)
            {
                try{
                    if((((ApplicationInfo) MethodList[checkMethod].invoke(activity , new Object[]{})).flags & 0x40000 /* ApplicationInfo.FLAG_EXTERNAL_STORAGE*/ ) != 0 )
                        flag = true;
                }
                catch(Exception e) {}
            }
        }
    }
    return flag;
}
TestUtilities.java 文件源码 项目:otp-authenticator-android 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
KP2AKeyboard.java 文件源码 项目:keepass2android 阅读 29 收藏 0 点赞 0 评论 0
protected void launchSettings (Class<? extends PreferenceActivity> settingsClass) {
    handleClose();
    Intent intent = new Intent();
    intent.setClass(KP2AKeyboard.this, settingsClass);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}
ActivityUtils.java 文件源码 项目:MovieGuide 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Launches Settings Activity.
 * @param context context
 */
public static void launchSettingsActivity(final Context context) {
    Intent intent = new Intent(context, SettingsActivity.class);
    intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT,
            SettingsActivity.GeneralPreferenceFragment.class.getName() );
    intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true );
    intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, R.string.action_settings);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
ContactsPickerActivity.java 文件源码 项目:custode 阅读 33 收藏 0 点赞 0 评论 0
@Nullable
@Override
public Intent getParentActivityIntent() {
    Intent intent = new Intent(this, SettingsActivity.class);
    intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment.class.getName());
    intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
    return intent;
}
UserDictionaryAddWordFragment.java 文件源码 项目:AOSP-Kayboard-7.1.2 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int pos,
        final long id) {
    final LocaleRenderer locale = (LocaleRenderer)parent.getItemAtPosition(pos);
    if (locale.isMoreLanguages()) {
        PreferenceActivity preferenceActivity = (PreferenceActivity)getActivity();
        preferenceActivity.startPreferenceFragment(new UserDictionaryLocalePicker(), true);
    } else {
        mContents.updateLocale(locale.getLocaleString());
    }
}
MainActivity.java 文件源码 项目:AccountBook 阅读 22 收藏 0 点赞 0 评论 0
@Override
protected void onPause() {
    super.onPause();
    SharedPreferences sharedPreferences = getSharedPreferences("USERPASS", PreferenceActivity.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString("username", "shenyanfang");
    editor.putString("password", "guess");
    editor.commit();
}
KP2AKeyboard.java 文件源码 项目:KeePass2Android 阅读 31 收藏 0 点赞 0 评论 0
protected void launchSettings (Class<? extends PreferenceActivity> settingsClass) {
    handleClose();
    Intent intent = new Intent();
    intent.setClass(KP2AKeyboard.this, settingsClass);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}


问题


面经


文章

微信
公众号

扫码关注公众号