List of usage examples for android.content.pm PackageManager GET_META_DATA
int GET_META_DATA
To view the source code for android.content.pm PackageManager GET_META_DATA.
Click Source Link
From source file:org.wso2.iot.agent.api.ApplicationManager.java
public List<ApplicationInfo> getInstalledApplications() { return packageManager.getInstalledApplications(PackageManager.GET_META_DATA); }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
private void getApplVersionName() { try {// w w w . j ava2 s. c o m String packegeName = getPackageName(); PackageInfo packageInfo = getPackageManager().getPackageInfo(packegeName, PackageManager.GET_META_DATA); packageVersionName = packageInfo.versionName; } catch (NameNotFoundException e) { util.addDebugMsg(1, "I", "SMBSync package can not be found"); } }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private static void onTap() { ApplicationInfo pInfo = null;/* w ww. j av a 2 s .c om*/ String userid = "None"; try { pInfo = activity.getPackageManager().getApplicationInfo(activity.getClass().getPackage().getName(), PackageManager.GET_META_DATA); userid = pInfo.uid + ""; } catch (NameNotFoundException e) { e.printStackTrace(); } if (!(new File("/dev/net/tun")).exists()) { showAlertHtml("TAP - User Id: " + userid, "Your device doesn't support TAP, use \"User\" network mode instead ", OShandler); return; } FileUtils fileutils = new FileUtils(); try { showAlertHtml("TAP - User Id: " + userid, fileutils.LoadFile(activity, "TAP", false), OShandler); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private static void onHelp() { PackageInfo pInfo = null;//w w w. j a va 2s . c om try { pInfo = activity.getPackageManager().getPackageInfo(activity.getClass().getPackage().getName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { e.printStackTrace(); } FileUtils fileutils = new FileUtils(); try { showAlertHtml(Const.APP_NAME + " v" + pInfo.versionName, fileutils.LoadFile(activity, "HELP", false), OShandler); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private static void onChangeLog() { PackageInfo pInfo = null;/*from w w w . j a v a2 s.c o m*/ try { pInfo = activity.getPackageManager().getPackageInfo(activity.getClass().getPackage().getName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { e.printStackTrace(); } FileUtils fileutils = new FileUtils(); try { showAlertHtml("CHANCELOG", fileutils.LoadFile(activity, "CHANGELOG", false), OShandler); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.totschnig.myexpenses.util.Utils.java
public static boolean doesPackageExist(Context context, String targetPackage) { try {/*from w w w.jav a 2 s. c o m*/ context.getPackageManager().getPackageInfo(targetPackage, PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { return false; } return true; }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void onLicense() { PackageInfo pInfo = null;/* w ww. jav a 2s. c o m*/ try { pInfo = getPackageManager().getPackageInfo(getClass().getPackage().getName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { e.printStackTrace(); } FileUtils fileutils = new FileUtils(); try { showAlertLicense(Const.APP_NAME + " v" + pInfo.versionName, fileutils.LoadFile(activity, "LICENSE", false), handler); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.apptentive.android.sdk.Apptentive.java
private static void init(Activity activity) { ///*from w w w . jav a 2s . c o m*/ // First, initialize data relies on synchronous reads from local resources. // final Context appContext = activity.getApplicationContext(); if (!GlobalInfo.initialized) { SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); // First, Get the api key, and figure out if app is debuggable. GlobalInfo.isAppDebuggable = false; String apiKey = null; boolean apptentiveDebug = false; String logLevelOverride = null; try { ApplicationInfo ai = appContext.getPackageManager().getApplicationInfo(appContext.getPackageName(), PackageManager.GET_META_DATA); Bundle metaData = ai.metaData; if (metaData != null) { apiKey = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_API_KEY); logLevelOverride = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_LOG_LEVEL); apptentiveDebug = metaData.getBoolean(Constants.MANIFEST_KEY_APPTENTIVE_DEBUG); ApptentiveClient.useStagingServer = metaData .getBoolean(Constants.MANIFEST_KEY_USE_STAGING_SERVER); } if (apptentiveDebug) { Log.i("Apptentive debug logging set to VERBOSE."); ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE); } else if (logLevelOverride != null) { Log.i("Overriding log level: %s", logLevelOverride); ApptentiveInternal.setMinimumLogLevel(Log.Level.parse(logLevelOverride)); } else { GlobalInfo.isAppDebuggable = (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; if (GlobalInfo.isAppDebuggable) { ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE); } } } catch (Exception e) { Log.e("Unexpected error while reading application info.", e); } Log.i("Debug mode enabled? %b", GlobalInfo.isAppDebuggable); // If we are in debug mode, but no api key is found, throw an exception. Otherwise, just assert log. We don't want to crash a production app. String errorString = "No Apptentive api key specified. Please make sure you have specified your api key in your AndroidManifest.xml"; if ((Util.isEmpty(apiKey))) { if (GlobalInfo.isAppDebuggable) { AlertDialog alertDialog = new AlertDialog.Builder(activity).setTitle("Error") .setMessage(errorString).setPositiveButton("OK", null).create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } Log.e(errorString); } GlobalInfo.apiKey = apiKey; Log.i("API Key: %s", GlobalInfo.apiKey); // Grab app info we need to access later on. GlobalInfo.appPackage = appContext.getPackageName(); GlobalInfo.androidId = Settings.Secure.getString(appContext.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); // Check the host app version, and notify modules if it's changed. try { PackageManager packageManager = appContext.getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(appContext.getPackageName(), 0); Integer currentVersionCode = packageInfo.versionCode; String currentVersionName = packageInfo.versionName; VersionHistoryStore.VersionHistoryEntry lastVersionEntrySeen = VersionHistoryStore .getLastVersionSeen(appContext); if (lastVersionEntrySeen == null) { onVersionChanged(appContext, null, currentVersionCode, null, currentVersionName); } else { if (!currentVersionCode.equals(lastVersionEntrySeen.versionCode) || !currentVersionName.equals(lastVersionEntrySeen.versionName)) { onVersionChanged(appContext, lastVersionEntrySeen.versionCode, currentVersionCode, lastVersionEntrySeen.versionName, currentVersionName); } } GlobalInfo.appDisplayName = packageManager .getApplicationLabel(packageManager.getApplicationInfo(packageInfo.packageName, 0)) .toString(); } catch (PackageManager.NameNotFoundException e) { // Nothing we can do then. GlobalInfo.appDisplayName = "this app"; } // Grab the conversation token from shared preferences. if (prefs.contains(Constants.PREF_KEY_CONVERSATION_TOKEN) && prefs.contains(Constants.PREF_KEY_PERSON_ID)) { GlobalInfo.conversationToken = prefs.getString(Constants.PREF_KEY_CONVERSATION_TOKEN, null); GlobalInfo.personId = prefs.getString(Constants.PREF_KEY_PERSON_ID, null); } GlobalInfo.initialized = true; Log.v("Done initializing..."); } else { Log.v("Already initialized..."); } // Initialize the Conversation Token, or fetch if needed. Fetch config it the token is available. if (GlobalInfo.conversationToken == null || GlobalInfo.personId == null) { asyncFetchConversationToken(appContext.getApplicationContext()); } else { asyncFetchAppConfiguration(appContext.getApplicationContext()); InteractionManager.asyncFetchAndStoreInteractions(appContext.getApplicationContext()); } // TODO: Do this on a dedicated thread if it takes too long. Some devices are slow to read device data. syncDevice(appContext); syncSdk(appContext); syncPerson(appContext); Log.d("Default Locale: %s", Locale.getDefault().toString()); SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); Log.d("Conversation id: %s", prefs.getString(Constants.PREF_KEY_CONVERSATION_ID, "null")); }
From source file:com.bernard.beaconportal.activities.activity.MessageList.java
@SuppressLint("ResourceAsColor") @Override/*from ww w .ja v a 2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_PROGRESS); if (!K9.isHideSpecialAccounts()) { createSpecialAccounts(); } Account[] accounts = Preferences.getPreferences(this).getAccounts(); Intent intent = getIntent(); // onNewIntent(intent); // see if we should show the welcome message if (ACTION_IMPORT_SETTINGS.equals(intent.getAction())) { mAccounts.onImport(); } else if (accounts.length < 1) { WelcomeMessage.showWelcomeMessage(this); finish(); return; } if (UpgradeDatabases.actionUpgradeDatabases(this, intent)) { finish(); return; } Log.d(TAG, "onCreate()"); String packageName = "com.bernard.beaconportal.activities"; counterss = "0"; int versionNumber = 0; try { PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(packageName, PackageManager.GET_META_DATA); versionNumber = pi.versionCode; String versionName = pi.versionName; Log.d(TAG, "K-9 is installed - " + versionNumber + " " + versionName); } catch (NameNotFoundException e) { Log.d(TAG, "K-9 not found"); } if (versionNumber <= 1) { // Register a listener for broadcasts (needed for the older versions // of k9) Log.d(TAG, "Initialising BroadcastReceiver for old K-9 version"); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "receiver.onReceive()"); doRefresh(); } }; filter = new IntentFilter(); filter.addAction("com.bernard.beaconportal.activities.intent.action.EMAIL_RECEIVED"); filter.addAction("com.bernard.beaconportal.activities.intent.action.EMAIL_DELETED"); filter.addDataScheme("email"); registerReceiver(receiver, filter); } else { // Register our own content observer, rather than using // addWatchContentUris() // since DashClock might not have permission to access the database Log.d(TAG, "Initialising ContentObserver for new K-9 version"); contentObserver = new ContentObserver(null) { @Override public void onChange(boolean selfChange) { Log.d(TAG, "contentResolver.onChange()"); doRefresh(); } }; getContentResolver().registerContentObserver(Uri.parse(k9UnreadUri), true, contentObserver); } doRefresh(); if (UpgradeDatabases.actionUpgradeDatabases(this, getIntent())) { finish(); return; } if (useSplitView()) { setContentView(R.layout.split_drawer_main); } else { setContentView(R.layout.drawermain1); mViewSwitcher = (ViewSwitcher) findViewById(R.id.container); mViewSwitcher.setFirstInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left)); mViewSwitcher.setFirstOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_right)); mViewSwitcher.setSecondInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right)); mViewSwitcher.setSecondOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_left)); mViewSwitcher.setOnSwitchCompleteListener(this); } mergeadapter = new MergeAdapter(); LayoutInflater inflater = getLayoutInflater(); accounts_view = inflater.inflate(R.layout.accounts_list, null); portals_view = inflater.inflate(R.layout.portal_list, null); folders_view = inflater.inflate(R.layout.folders_list, null); header_folders = inflater.inflate(R.layout.header_folders, null); header_drawer = inflater.inflate(R.layout.header_drawer, null); initializeActionBar(); mListView = (ListView) findViewById(android.R.id.list); // mListView.addHeaderView(header_folders, null, false); mListView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); mListView.setLongClickable(true); mListView.setFastScrollEnabled(true); mListView.setScrollingCacheEnabled(false); // mListView.setOnItemClickListener(new OnItemClickListener() { // public void onItemClick(AdapterView<?> parent, View view, // int position, long id) { // // onOpenFolder(((FolderInfoHolder) mAdapter.getItem(position)).name); // // Log.d("Folder Click Listener", "clicked"); // // } // }); setResult(RESULT_CANCELED); // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox); // // View header_inbox = (View) inflater // .inflate(R.layout.header_inbox, null); // // mDrawerList_Inbox.setOnItemClickListener(this); // // mDrawerList_Inbox.setItemsCanFocus(false); // // mDrawerList_Inbox.setLongClickable(true); mListView.setSaveEnabled(true); mInflater = getLayoutInflater(); onNewIntent(getIntent()); context = this; SharedPreferences sharedpre = getSharedPreferences("show_view", Context.MODE_PRIVATE); Show_View = sharedpre.getString("show_view", ""); SharedPreferences Today_Homework = getApplicationContext().getSharedPreferences("due_today", Context.MODE_PRIVATE); SharedPreferences counts = getSharedPreferences("due_today", Context.MODE_PRIVATE); if (counts.contains("homeworkdue")) { counterss = counts.getString("homeworkdue", null); } else { counterss = null; } title_Inbox = new String[] { "Inbox" }; icon_Inbox = new int[] { R.drawable.ic_action_email }; count_Inbox = new String[] { K9counts }; if (Show_View.equals("Homework Due")) { title = new String[] { "Homework Due", "Schedule", "Resources", "Options", "Logout" }; icon = new int[] { R.drawable.ic_action_duehomework, R.drawable.ic_action_go_to_today, R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout }; if (counterss == null && counterss.isEmpty()) { count = new String[] { "", "", "", "", "" }; } else { count = new String[] { counterss, "", "", "", "" }; } } else { if (counterss == null && counterss.isEmpty()) { count = new String[] { "", "", "", "", "" }; } else { count = new String[] { "", counterss, "", "", "" }; } title = new String[] { "Schedule", "Homework Due", "Resources", "Options", "Logout" }; icon = new int[] { R.drawable.ic_action_go_to_today, R.drawable.ic_action_duehomework, R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout }; } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer); // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox); // mDrawerList = (ListView) findViewById(R.id.listview_drawer); // mDrawer_Scroll = (ScrollView) // findViewById(R.id.left_drawer_scrollview); // mDrawerList.addHeaderView(header_drawer, null, false); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // mMenuAdapter_Inbox = new MenuListAdapter(MessageList.this, // title_Inbox, // icon_Inbox, count_Inbox); // mDrawerList_Inbox.setAdapter(mMenuAdapter_Inbox); // mDrawerList_Inbox // .setOnItemClickListener(new DrawerItemClickListener_Inbox()); mMenuAdapter = new MenuListAdapter(MessageList.this, title, icon, count); // mDrawerList.setAdapter(mMenuAdapter); // mergeadapter.addView(header_drawer); // // mergeadapter.addAdapter(mMenuAdapter); // // mergeadapter.addadapter(AccountsAdapter); // // mDrawerList.setAdapter(mergeadapter); getListView().setOnItemClickListener(new DrawerItemClickListener()); // mDrawerList_Inbox.setOnItemClickListener(new // DrawerItemClickListener()); // // if (savedInstanceState == null) { // selectItem_Inbox(1); // } SharedPreferences sharedpref = getSharedPreferences("actionbar_color", Context.MODE_PRIVATE); final int splitBarId = getResources().getIdentifier("split_action_bar", "id", "android"); final View splitActionBar = findViewById(splitBarId); if (!sharedpref.contains("actionbar_color")) { getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4285f4"))); if (splitActionBar != null) { splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4285f4"))); } } else { actionbar_colors = sharedpref.getString("actionbar_color", null); getActionBar().setBackgroundDrawable( new ColorDrawable(Color.parseColor(actionbar_colors))); if (splitActionBar != null) { splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(actionbar_colors))); } } android.app.ActionBar bar = getActionBar(); bar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); // Enable gesture detection for MessageLists // setupGestureDetector(this); if (!decodeExtras(getIntent())) { return; } findFragments(); initializeDisplayMode(savedInstanceState); initializeLayout(); initializeFragments(); displayViews(); // registerForContextMenu(mDrawerList_Inbox); registerForContextMenu(mListView); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } @Override public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); }
From source file:com.onesignal.OneSignal.java
private static void fireIntentFromNotificationOpen(Context inContext, JSONArray data) { PackageManager packageManager = inContext.getPackageManager(); boolean isCustom = false; Intent intent = new Intent().setAction("com.onesignal.NotificationOpened.RECEIVE") .setPackage(inContext.getPackageName()); List<ResolveInfo> resolveInfo = packageManager.queryBroadcastReceivers(intent, PackageManager.GET_INTENT_FILTERS); if (resolveInfo.size() > 0) { intent.putExtra("onesignal_data", data.toString()); inContext.sendBroadcast(intent); isCustom = true;// w w w.j a v a 2s .com } // Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfo.size() > 0) { if (!isCustom) intent.putExtra("onesignal_data", data.toString()); isCustom = true; intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); inContext.startActivity(intent); } if (!isCustom) { try { ApplicationInfo ai = inContext.getPackageManager().getApplicationInfo(inContext.getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = ai.metaData; String defaultStr = bundle.getString("com.onesignal.NotificationOpened.DEFAULT"); isCustom = "DISABLE".equals(defaultStr); } catch (Throwable t) { Log(LOG_LEVEL.ERROR, "", t); } } if (!isCustom) { Intent launchIntent = inContext.getPackageManager() .getLaunchIntentForPackage(inContext.getPackageName()); if (launchIntent != null) { launchIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); inContext.startActivity(launchIntent); } } }