Search in sources :

Example 96 with PackageManager

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);
        }
    }
}
Also used : IKlyphFragment(com.abewy.android.apps.klyph.fragment.IKlyphFragment) FragmentTransaction(android.app.FragmentTransaction) PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Bundle(android.os.Bundle) Intent(android.content.Intent) LoginFragment(com.abewy.android.apps.klyph.fragment.LoginFragment) Fragment(android.app.Fragment) IKlyphFragment(com.abewy.android.apps.klyph.fragment.IKlyphFragment)

Example 97 with PackageManager

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;
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo)

Example 98 with PackageManager

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;
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo)

Example 99 with PackageManager

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;
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 100 with PackageManager

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;
}
Also used : PackageManager(android.content.pm.PackageManager) TelephonyManager(android.telephony.TelephonyManager) UUID(java.util.UUID)

Aggregations

PackageManager (android.content.pm.PackageManager)1429 Intent (android.content.Intent)483 ResolveInfo (android.content.pm.ResolveInfo)449 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)345 ApplicationInfo (android.content.pm.ApplicationInfo)249 PackageInfo (android.content.pm.PackageInfo)248 ComponentName (android.content.ComponentName)239 ArrayList (java.util.ArrayList)156 ActivityInfo (android.content.pm.ActivityInfo)135 IOException (java.io.IOException)126 RemoteException (android.os.RemoteException)105 IPackageManager (android.content.pm.IPackageManager)93 Drawable (android.graphics.drawable.Drawable)93 Resources (android.content.res.Resources)90 PendingIntent (android.app.PendingIntent)71 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Context (android.content.Context)63 Bundle (android.os.Bundle)60 HashMap (java.util.HashMap)53 ServiceInfo (android.content.pm.ServiceInfo)46