use of android.content.pm.PackageManager in project Klyph by jonathangerbaud.
the class MainActivity method updateContent.
private void updateContent(int selection) {
if (selection != oldSelection) {
Bundle bundle = new Bundle();
bundle.putString(KlyphBundleExtras.ELEMENT_ID, KlyphSession.getSessionUserId());
String className = classes.get(selection);
if (className.equals("com.abewy.android.apps.klyph.fragment.Chat")) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(MESSENGER_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
Intent intent = getPackageManager().getLaunchIntentForPackage(MESSENGER_PACKAGE_NAME);
startActivity(intent);
} catch (NameNotFoundException e) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MESSENGER_PLAY_STORE_URI));
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);
}
} else {
if (selection < navAdapter.getCount())
setTitle(navAdapter.getItem(selection));
else
setTitle(KlyphSession.getSessionUserName());
Fragment fragment = Fragment.instantiate(MainActivity.this, className, bundle);
if (previousFragment != null)
previousFragment.onSetToBack(this);
FragmentTransaction tx = getFragmentManager().beginTransaction();
tx.replace(R.id.main, fragment, FRAGMENT_TAG);
tx.commitAllowingStateLoss();
((IKlyphFragment) fragment).onSetToFront(this);
previousFragment = (IKlyphFragment) fragment;
navAdapter.setSelectedPosition(selection);
navAdapter.notifyDataSetChanged();
oldSelection = selection;
if (notificationsFragment != null)
notificationsFragment.setHasOptionsMenu(false);
}
}
}
use of android.content.pm.PackageManager in project SmartAndroidSource by jaychou2012.
the class SmartFragmentActivity method getVersionCode.
public int getVersionCode() {
try {
PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
int versionCode = info.versionCode;
return versionCode;
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}
use of android.content.pm.PackageManager in project SmartAndroidSource by jaychou2012.
the class SmartActivity method getVersionCode.
public int getVersionCode() {
try {
PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
int versionCode = info.versionCode;
return versionCode;
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}
use of android.content.pm.PackageManager in project SmartAndroidSource by jaychou2012.
the class AssistTool method getVersionCode.
public int getVersionCode() {
try {
PackageManager manager = c.getPackageManager();
PackageInfo info = manager.getPackageInfo(c.getPackageName(), 0);
int versionCode = info.versionCode;
return versionCode;
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}
use of android.content.pm.PackageManager in project Klyph by jonathangerbaud.
the class Android method getDeviceUDID.
public static String getDeviceUDID(Context ctx) {
final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
PackageManager pm = ctx.getPackageManager();
int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
if (hasPerm == PackageManager.PERMISSION_GRANTED) {
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
} else {
tmDevice = Settings.Secure.ANDROID_ID;
tmSerial = android.os.Build.SERIAL;
}
androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
return deviceId;
}
Aggregations