use of android.content.pm.PackageInfo in project cw-omnibus by commonsguy.
the class AbstractCPProxy method onCreate.
@Override
public boolean onCreate() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean(PREFS_FIRST_RUN, true)) {
SharedPreferences.Editor editor = prefs.edit().putBoolean(PREFS_FIRST_RUN, false);
HashMap<PackageInfo, ArrayList<PermissionLint>> entries = PermissionUtils.checkCustomPermissions(getContext());
for (Map.Entry<PackageInfo, ArrayList<PermissionLint>> entry : entries.entrySet()) {
if (!"com.commonsware.android.cpproxy.consumer".equals(entry.getKey().packageName)) {
tainted = true;
break;
}
}
editor.putBoolean(PREFS_TAINTED, tainted).apply();
} else {
tainted = prefs.getBoolean(PREFS_TAINTED, true);
}
return (true);
}
use of android.content.pm.PackageInfo in project materialistic by hidroh.
the class ReleaseNotesActivityTest method testUpdateSeen.
@Test
public void testUpdateSeen() throws PackageManager.NameNotFoundException {
Preferences.sReleaseNotesSeen = null;
PreferenceManager.getDefaultSharedPreferences(RuntimeEnvironment.application).edit().putInt(RuntimeEnvironment.application.getString(R.string.pref_latest_release), BuildConfig.LATEST_RELEASE).commit();
PackageInfo info = RuntimeEnvironment.getPackageManager().getPackageInfo(RuntimeEnvironment.application.getPackageName(), 0);
info.firstInstallTime = 0;
info.lastUpdateTime = 1;
assertTrue(Preferences.isReleaseNotesSeen(RuntimeEnvironment.application));
}
use of android.content.pm.PackageInfo in project detective-droid by michaelcarrano.
the class AppDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_detail);
int position = getIntent().getExtras().getInt(AppDetailFragment.ARG_ITEM_ID);
// Show the Up button in the action bar.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Set the ActionBar title, icon and up button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
PackageManager pm = getPackageManager();
PackageInfo pkg = AppSources.getInstance().getSources().get(position).getPackageInfo();
getSupportActionBar().setIcon(pkg.applicationInfo.loadIcon(pm));
getSupportActionBar().setTitle(pm.getApplicationLabel(pkg.applicationInfo).toString());
// at: http://developer.android.com/guide/components/fragments.html
if (savedInstanceState == null) {
// Create the detail fragment and add it to the activity
// using a fragment transaction.
Bundle arguments = new Bundle();
arguments.putInt(AppDetailFragment.ARG_ITEM_ID, position);
AppDetailFragment fragment = new AppDetailFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction().add(R.id.app_detail_container, fragment).commit();
}
}
use of android.content.pm.PackageInfo in project AboutLibraries by mikepenz.
the class Libs method getAutoDetectedLibraries.
/**
* Get all autoDetected Libraries
*
* @return an ArrayList Library with all found libs by their classpath
*/
public ArrayList<Library> getAutoDetectedLibraries(Context ctx) {
ArrayList<Library> libraries = new ArrayList<>();
PackageInfo pi = Util.getPackageInfo(ctx);
if (pi != null) {
String[] autoDetectedLibraries = ctx.getSharedPreferences("aboutLibraries_" + pi.versionCode, Context.MODE_PRIVATE).getString("autoDetectedLibraries", "").split(";");
if (autoDetectedLibraries.length > 0) {
for (String autoDetectedLibrary : autoDetectedLibraries) {
Library lib = getLibrary(autoDetectedLibrary);
if (lib != null) {
libraries.add(lib);
}
}
}
}
if (libraries.size() == 0) {
String delimiter = "";
String autoDetectedLibrariesPref = "";
for (Library lib : Detect.detect(ctx, getLibraries())) {
libraries.add(lib);
autoDetectedLibrariesPref = autoDetectedLibrariesPref + delimiter + lib.getDefinedName();
delimiter = ";";
}
if (pi != null) {
ctx.getSharedPreferences("aboutLibraries_" + pi.versionCode, Context.MODE_PRIVATE).edit().putString("autoDetectedLibraries", autoDetectedLibrariesPref).commit();
}
}
return libraries;
}
use of android.content.pm.PackageInfo in project NewPipe by TeamNewPipe.
the class CrashHandler method init.
public static void init(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
VERSION = info.versionName + info.versionCode;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations