List of usage examples for android.content ComponentName getClassName
public @NonNull String getClassName()
From source file:com.netcompss.ffmpeg4android_client.BaseWizard.java
protected void startService() { if (started) { // Toast.makeText(this, "Service already started", Toast.LENGTH_SHORT).show(); } else {/*from w w w . ja va 2s. c om*/ Intent i = new Intent("com.netcompss.ffmpeg4android.FFMpegRemoteServiceBridge"); if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) { i.setPackage("com.netcompss.ffmpeg4android"); } PackageManager packageManager = getPackageManager(); List<ResolveInfo> services = packageManager.queryIntentServices(i, 0); Log.i(Prefs.TAG, "!!!!!!!!!!!!!!!!!!services.size(): " + services.size()); if (services.size() > 0) { ResolveInfo service = services.get(0); i.setClassName(service.serviceInfo.packageName, service.serviceInfo.name); i.setAction("com.netcompss.ffmpeg4android.FFMpegRemoteServiceBridge"); if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) { i.setPackage("com.netcompss.ffmpeg4android"); } if (!invokeFileInfoServiceFlag) { i.addCategory("Base"); Log.i(Prefs.TAG, "putting Base categoty"); } else { i.addCategory("Info"); Log.i(Prefs.TAG, "putting Info categoty"); } ComponentName cn = startService(i); Log.d(Prefs.TAG, "started: " + cn.getClassName()); } started = true; Log.d(Prefs.TAG, "Client startService()"); } }
From source file:com.lewa.crazychapter11.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //set to full screen // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ///set to no title // requestWindowFeature(Window.FEATURE_NO_TITLE); // acionBar = getSupportActionBar(); // acionBar = getActionBar(); // acionBar.hide(); // Window win = getWindow(); // win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // win.setStatusBarColor(Color.TRANSPARENT); // win.setNavigationBarColor(Color.TRANSPARENT); /*///from www .j a va 2 s. c om win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); win.setStatusBarColor(Color.TRANSPARENT); win.setNavigationBarColor(Color.TRANSPARENT); //*/ super.onCreate(savedInstanceState); setContentView(R.layout.main); /* setTheme(R.style.CrazyTheme); */ AddGameBtn(); AddNoification(); LookupContact(); AddServiceBtn(); broadcastMain(); mediaPlayerMain(); mediaRecordSoundMain(); cameraMain(); recordvideoMain(); queMySql(); TestFragment(); justForTest(); LoadJson(); AddTestBtn(); AddUsageStatsBtn(); AddPeopleProvideBtn(); getInput(); ////just for test shutdown broadcast receiver IntentFilter mIntentFilter = new IntentFilter("android.intent.action.ACTION_SHUTDOWN"); mIntentFilter.addAction("com.lewa.alarm.test"); mIntentFilter.addAction("android.provider.Telephony.SECRET_CODE"); mIntentFilter.addAction("android.intent.action.SCREEN_ON"); mIntentFilter.addAction("android.intent.action.SCREEN_OFF"); mShoutdown = new shutdownReceiver(); registerReceiver(mShoutdown, mIntentFilter); ////test preferences = getSharedPreferences("crazyit", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editor = preferences.edit(); preferencestime = getSharedPreferences("RMS_Shutdown_time", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editortime = preferencestime.edit(); SharedShutdownTimeRead(); AddSharedPreBtn(); etNum = (EditText) findViewById(R.id.etNum); // // int maxLength = 4; InputFilter[] fArray = new InputFilter[1]; fArray[0] = new InputFilter.LengthFilter(maxLength); etNum.setFilters(fArray); // // calThread = new CalThread(); calThread.start(); Log.i("algerheMain", "MainActivity onCreate in!!"); String page = getString(R.string.str_page, "345", "24"); Log.i("algerheMain", "page=" + page); // /just for test here ComponentName comp = getIntent().getComponent(); show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText( "??" + comp.getPackageName() + " \n ??" + comp.getClassName()); ////MD5 check item ///1.IMEI TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); String szImei = TelephonyMgr.getDeviceId(); String m_szSIMSerialNm = TelephonyMgr.getSimSerialNumber(); CellLocation m_location = TelephonyMgr.getCellLocation(); String m_Line1Number = TelephonyMgr.getLine1Number(); String m_OperatorName = TelephonyMgr.getSimOperatorName(); Log.i("algerheTelephonyMgr", "szImei=" + szImei); Log.i("algerheTelephonyMgr", "m_szSIMSerialNm=" + m_szSIMSerialNm); Log.i("algerheTelephonyMgr", "m_location=" + m_location); Log.i("algerheTelephonyMgr", "m_Line1Number=" + m_Line1Number); Log.i("algerheTelephonyMgr", "m_OperatorName=" + m_OperatorName); Log.i("algerheMain01", "szImei=" + szImei); Log.i("algerheMain01", "m_szSIMSerialNm=" + m_szSIMSerialNm); ///2.Pseudo-Unique ID String m_szDevIDShort = "35" + //we make this look like a valid IMEI Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 digits Log.i("algerheMain01", "m_szDevIDShort=" + m_szDevIDShort); ///3. Android ID String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.i("algerheMain01", "m_szAndroidID=" + m_szAndroidID); ///4.WLAN MAC Address string WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); String m_szWLANMAC = "unknow_wifi_mac"; if (wm != null && wm.getConnectionInfo() != null) { m_szWLANMAC = wm.getConnectionInfo().getMacAddress(); } Log.i("algerheMain01", "m_szWLANMAC=" + m_szWLANMAC); ///5.BT MAC Address string BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String m_szBTMAC = m_BluetoothAdapter.getAddress(); Log.i("algerheMain01", "m_szBTMAC=" + m_szBTMAC); ///6.sim serial number .getSimSerialNumber() // / ///reflect test checkMethod(); // */ final Intent alarmIntent = new Intent(); Log.i("algerheMain00", "isLewaRom=" + isLewaRom(this, alarmIntent)); handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0x4567) { String languageStr = null; String countryStr = null; Locale[] locList = Locale.getAvailableLocales(); for (int i = 0; i < locList.length; i++) { languageStr += locList[i].getLanguage(); countryStr += locList[i].getCountry(); } // show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText("" + languageStr + " \n " + countryStr); } else if (msg.what == 0x2789) { Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis() + "\n action=" + alarmIntent.getAction()); // sendBroadcast(alarmIntent); } } }; // String strApkPath = intent.getStringExtra("apkPath"); // String strCmd = "pm install -r " + strApkPath; // try { // Process install = Runtime.getRuntime().exec(strCmd); // Log.d(TAG, "install = " + install + ", strCmd =" + strCmd); // }catch (Exception ex){ // Log.d(TAG, ex.getMessage()); // } // */ }
From source file:com.android.leanlauncher.IconCache.java
/** * Retrieves the entry from the cache. If the entry is not present, it creates a new entry. * This method is not thread safe, it must be called from a synchronized method. *//* w w w . j a va 2 s . c o m*/ private CacheEntry cacheLocked(ItemInfo itemInfo, ComponentName componentName, LauncherActivityInfoCompat info, UserHandleCompat user, Map<Object, CharSequence> labelCache, boolean usePackageIcon) { CacheKey cacheKey = new CacheKey(componentName, user); CacheEntry entry = mCache.get(cacheKey); if (entry == null || entry.icon == null) { entry = new CacheEntry(); if (info != null) { ComponentName labelKey = info.getComponentName(); if (labelCache != null && labelCache.containsKey(labelKey)) { entry.title = labelCache.get(labelKey).toString(); } else { entry.title = info.getLabel().toString(); if (labelCache != null) { labelCache.put(labelKey, entry.title); } } entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user); Drawable defaultDrawable = info.getBadgedIcon(mIconDpi); if (itemInfo != null && itemInfo.iconResource != null && itemInfo.iconResource.resourceName != null && mCurrentIconTheme.equals(itemInfo.iconResource.packageName)) { // no icon theme changes, so fetch from theme directly entry.icon = createIconBitmapFromTheme(itemInfo.iconResource.resourceName, defaultDrawable); } else if (!TextUtils.isEmpty(mCurrentIconTheme)) { entry.icon = createNewIconBitmap(itemInfo, componentName.getPackageName(), componentName.getClassName(), defaultDrawable); } if (entry.icon == null) { // pick default icon entry.icon = Utilities.createIconBitmap(defaultDrawable, mContext); } mCache.put(cacheKey, entry); } else { entry.title = ""; if (usePackageIcon) { entry = getEntryForPackage(componentName.getPackageName(), user); Log.d(TAG, "using package default icon for " + componentName.toShortString()); } if (entry.icon == null) { Log.d(TAG, "using default icon for " + componentName.toShortString()); entry.icon = getDefaultUserIcon(user); } } } return entry; }
From source file:com.linkbubble.Settings.java
public ResolveInfo getDefaultAppForUrl(URL url, List<ResolveInfo> resolveInfos) { if (resolveInfos == null || resolveInfos.size() == 0) { return null; }//from ww w.jav a 2 s . co m String host = url.getHost(); if (host.length() > 1) { String flattenedComponentName = mDefaultAppsMap.get(host); if (flattenedComponentName != null) { ComponentName componentName = ComponentName.unflattenFromString(flattenedComponentName); if (componentName != null) { for (ResolveInfo resolveInfo : resolveInfos) { // Handle crash: https://fabric.io/brave6/android/apps/com.linkbubble.playstore/issues/5623e787f5d3a7f76be5b166 if (resolveInfo == null || resolveInfo.activityInfo == null) { CrashTracking.log("Null resolveInfo when getting default for app: " + resolveInfo); continue; } if (resolveInfo.activityInfo.packageName.equals(componentName.getPackageName()) && resolveInfo.activityInfo.name.equals(componentName.getClassName())) { return resolveInfo; } } if (componentName.getPackageName().equals(mContext.getPackageName())) { return mLinkBubbleEntryActivityResolveInfo; } } } } return null; }
From source file:com.android.leanlauncher.LauncherModel.java
/** * Make an ShortcutInfo object for a shortcut that is an application. *//*from w w w . ja v a 2 s . c om*/ public ShortcutInfo getShortcutInfo(Intent intent, UserHandleCompat user, int titleIndex, Map<Object, CharSequence> labelCache, boolean allowMissingTarget) { if (user == null) { Log.d(TAG, "Null user found in getShortcutInfo"); return null; } ComponentName componentName = intent.getComponent(); if (componentName == null) { Log.d(TAG, "Missing component found in getShortcutInfo"); return null; } Intent newIntent = new Intent(intent.getAction(), null); newIntent.addCategory(Intent.CATEGORY_LAUNCHER); newIntent.setComponent(componentName); LauncherActivityInfoCompat lai = mLauncherApps.resolveActivity(newIntent, user); if ((lai == null) && !allowMissingTarget) { Log.d(TAG, "Missing activity found in getShortcutInfo: " + componentName); return null; } final ShortcutInfo info = new ShortcutInfo(); // From the cache. if (labelCache != null) { info.title = labelCache.get(componentName); } // from the resource if (info.title == null && lai != null) { info.title = lai.getLabel(); if (labelCache != null) { labelCache.put(componentName, info.title); } } // from the db if (info.title == null) { if (mApp.getContext() != null) { info.title = mApp.getContext().getString(titleIndex); } } // fall back to the class name of the activity if (info.title == null) { info.title = componentName.getClassName(); } info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; info.user = user; info.contentDescription = mUserManager.getBadgedLabelForUser(info.title.toString(), info.user); return info; }
From source file:com.android.leanlauncher.LauncherTransitionable.java
boolean startApplicationUninstallActivity(ComponentName componentName, int flags, UserHandleCompat user) { if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. int messageId = R.string.uninstall_system_app_text; Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show(); return false; } else {/*from w w w . jav a2s. c om*/ String packageName = componentName.getPackageName(); String className = componentName.getClassName(); Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (user != null) { user.addToIntent(intent, Intent.EXTRA_USER); } startActivity(intent); return true; } }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String StartJavaPrg(String[] sArgs, Intent preIntent) { String sRet = ""; String sArgList = ""; String sUrl = ""; // String sRedirFileName = ""; Intent prgIntent = null;/*from w w w . j a va 2 s . c om*/ Context ctx = contextWrapper.getApplicationContext(); PackageManager pm = ctx.getPackageManager(); if (preIntent == null) prgIntent = new Intent(); else prgIntent = preIntent; prgIntent.setPackage(sArgs[0]); prgIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Get the main activity for this package try { final ComponentName c = pm.getLaunchIntentForPackage(sArgs[0]).getComponent(); prgIntent.setClassName(c.getPackageName(), c.getClassName()); } catch (Exception e) { e.printStackTrace(); return "Unable to find main activity for package: " + sArgs[0]; } if (sArgs.length > 1) { if (sArgs[0].contains("android.browser")) prgIntent.setAction(Intent.ACTION_VIEW); else prgIntent.setAction(Intent.ACTION_MAIN); if (sArgs[0].contains("fennec") || sArgs[0].contains("firefox")) { sArgList = ""; sUrl = ""; for (int lcv = 1; lcv < sArgs.length; lcv++) { if (sArgs[lcv].contains("://")) { prgIntent.setAction(Intent.ACTION_VIEW); sUrl = sArgs[lcv]; } else { if (sArgs[lcv].equals(">")) { lcv++; if (lcv < sArgs.length) lcv++; // sRedirFileName = sArgs[lcv++]; } else sArgList += " " + sArgs[lcv]; } } if (sArgList.length() > 0) prgIntent.putExtra("args", sArgList.trim()); if (sUrl.length() > 0) prgIntent.setData(Uri.parse(sUrl.trim())); } else { for (int lcv = 1; lcv < sArgs.length; lcv++) sArgList += " " + sArgs[lcv]; prgIntent.setData(Uri.parse(sArgList.trim())); } } else { prgIntent.setAction(Intent.ACTION_MAIN); } try { contextWrapper.startActivity(prgIntent); FindProcThread findProcThrd = new FindProcThread(contextWrapper, sArgs[0]); findProcThrd.start(); findProcThrd.join(7000); if (!findProcThrd.bFoundIt && !findProcThrd.bStillRunning) { sRet = "Unable to start " + sArgs[0] + ""; } } catch (ActivityNotFoundException anf) { anf.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } ctx = null; return (sRet); }
From source file:com.android.soma.Launcher.java
boolean startApplicationUninstallActivity(ComponentName componentName, int flags) { if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. int messageId = R.string.uninstall_system_app_text; Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show(); return false; } else {/*ww w .j av a 2 s . c o m*/ String packageName = componentName.getPackageName(); String className = componentName.getClassName(); Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(intent); return true; } }