Example usage for android.content Context getClass

List of usage examples for android.content Context getClass

Introduction

In this page you can find the example usage for android.content Context getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:it.cdpaf.helper.DrawableManager.java

public static void fetchDrawableOnThread(final Product product, final ImageView imageView, final Context ctx) {
    final String urlString = Const.IMAGE_URL + product.getPercorsoImmagine();
    if (drawableMap.containsKey(urlString)) {
        Log.d(ctx.getClass().getSimpleName(), "DRAWABLE MANAGER FDOT:" + "RIUSO, Size:" + drawableMap.size());
        imageView.setImageDrawable(drawableMap.get(urlString));
        return;/*from  www. j  av  a  2 s.  c o  m*/
        //product.setImmagine(drawableMap.get(urlString));
    }

    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            Drawable dr = (Drawable) message.obj;
            imageView.setImageDrawable(dr);
            product.setImmagine(dr);
        }
    };

    Thread thread = new Thread() {
        @Override
        public void run() {
            //TODO : set imageView to a "pending" image
            Drawable d = ctx.getResources().getDrawable(R.drawable.blank);
            Message messagea = handler.obtainMessage(1, d);
            handler.sendMessage(messagea);
            Drawable drawable = fetchDrawable(urlString, ctx);

            Message messageb = handler.obtainMessage(1, drawable);
            handler.sendMessage(messageb);
        }
    };
    Log.i("DRAWABLE MANAGER:", "LANCIO FDOT, Size:" + drawableMap.size());
    thread.start();
}

From source file:net.reichholf.dreamdroid.DreamDroid.java

/**
 * @param context/*from w w w .  j  ava2s . com*/
 * @return
 */
public static String getVersionString(Context context) {
    try {
        ComponentName comp = new ComponentName(context, context.getClass());
        PackageInfo pinfo = context.getPackageManager().getPackageInfo(comp.getPackageName(), 0);
        return String.format("dreamDroid %s (%s)\n Stephan Reichholf\nstephan@reichholf.net",
                pinfo.versionName, pinfo.versionCode);
    } catch (android.content.pm.PackageManager.NameNotFoundException e) {
        return "dreamDroid\n 2013 Stephan Reichholf\nstephan@reichholf.net";
    }
}

From source file:com.yutong.axxc.parents.view.common.ActivityUtils.java

public static void clearCash(final Context acitvity, String server_org_id, String local_org_id) {
    // ID?ID?????
    Logger.i(acitvity.getClass(), "? ??ID", server_org_id,
            "?ID:", local_org_id);
    if (!server_org_id.equals(local_org_id)) {
        // TODO /*from  ww w  .  j  ava 2  s . c om*/
        // ?
        //AlertInfoDao alertInfoDao = new AlertInfoDao(acitvity);
        // alertInfoDao.delAlertInfos(YtApplication.getInstance().getUid());
        // 
        //PhotoDao photoDao = new PhotoDao(acitvity);
        // photoDao.delAllPhotoInfos(YtApplication.getInstance().getUid());
        // 
        // VehicleDao vehicleDao = new VehicleDao(acitvity);
        // vehicleDao.delVehicleByUid(YtApplication.getInstance().getUid());
        // 
        // NewsInfoDao newsInfoDao = new NewsInfoDao(loginAcitvity);
        // newsInfoDao.delNewsInfos(userInfoBean.getUsrId());
    }
}

From source file:me.calebjones.spacelaunchnow.utils.Utils.java

public static String getVersionName(Context context) {
    try {//from  w ww .  ja  v  a 2 s .c o m
        ComponentName comp = new ComponentName(context, context.getClass());
        return context.getPackageManager().getPackageInfo(comp.getPackageName(), 0).versionName;
    } catch (android.content.pm.PackageManager.NameNotFoundException e) {
        return "Unknown";
    }
}

From source file:me.calebjones.spacelaunchnow.utils.Utils.java

public static int getVersionCode(Context context) {
    try {//w  w  w  .java2s. c o m
        ComponentName comp = new ComponentName(context, context.getClass());
        PackageInfo pinfo = context.getPackageManager().getPackageInfo(comp.getPackageName(), 0);
        return pinfo.versionCode;
    } catch (android.content.pm.PackageManager.NameNotFoundException e) {
        return 0;
    }
}

From source file:com.sentaroh.android.Utilities.LocalMountPoint.java

@SuppressLint("SdCardPath")
static public ArrayList<String> getLocalMountPointList(Context c) {
    String pkg_name = c.getClass().getPackage().getName();
    String primary_esd = getExternalStorageDir();
    ArrayList<String> ml = new ArrayList<String>();
    addMountPointPrimary(primary_esd, ml);
    File lf = new File("/storage");
    File[] fl_1 = lf.listFiles();
    if (fl_1 != null) {
        for (int i = 0; i < fl_1.length; i++) {
            if (fl_1[i].getName().equals("emulated")) {
                File tlf = new File("/storage/emulated");
                File[] tlist = tlf.listFiles();
                if (tlist != null) {
                    for (int j = 0; j < tlist.length; j++) {
                        addMountPointPrimary(tlist[j].getPath(), ml);
                    }/*  w  ww .  ja v a 2s. c o  m*/
                }
            } else {
                if (fl_1[i].getName().equals("sdcard0"))
                    addMountPointPrimary(fl_1[i].getPath(), ml);
                else if (fl_1[i].getName().equals("remote"))
                    addMountPointPrimary(fl_1[i].getPath(), ml);
                else if (fl_1[i].getName().equals("uicc0"))
                    addMountPointPrimary(fl_1[i].getPath(), ml);
                else
                    addMountPointPrimaryAndSecondary(fl_1[i].getPath(), ml, pkg_name);
            }
        }
    }

    lf = new File("/mnt");
    fl_1 = lf.listFiles();
    if (fl_1 != null) {
        for (int i = 0; i < fl_1.length; i++) {
            if (!fl_1[i].getPath().equals("/mnt/obb") && !fl_1[i].getPath().equals("/mnt/asec")) {
                addMountPointPrimary(fl_1[i].getPath(), ml);
            }
        }
    }

    addMountPointPrimary("/sdcard", ml);
    addMountPointPrimaryAndSecondary("/Removable/SD", ml, pkg_name);
    addMountPointPrimaryAndSecondary("/Removable/MicroSD", ml, pkg_name);

    addMountPointPrimary("/Removable/USBdisk1/Drive1", ml);
    addMountPointPrimary("/Removable/USBdisk2/Drive1", ml);
    addMountPointPrimary("/mnt/sdcard/usbStorage/sda1", ml);
    addMountPointPrimary("/mnt/sdcard/usbStorage/sdb1", ml);
    addMountPointPrimary("/mnt/sdcard/usbStorage/sdc1", ml);
    addMountPointPrimary("/mnt/sdcard/usbStorage/sdd1", ml);

    addMountPointPrimary(primary_esd + "/usbStorage/sda1", ml);
    addMountPointPrimary(primary_esd + "/usbStorage/sdb1", ml);
    addMountPointPrimary(primary_esd + "/usbStorage/sdc1", ml);
    addMountPointPrimary(primary_esd + "/usbStorage/sdd1", ml);

    String env = System.getenv("EXTERNAL_STORAGE2");
    if (env != null)
        addMountPointPrimaryAndSecondary(env, ml, pkg_name);

    addMountPointPrimaryAndSecondary("/storage/extSdCard", ml, pkg_name);
    addMountPointPrimaryAndSecondary("/mnt/extSdCard", ml, pkg_name);
    addMountPointPrimaryAndSecondary("/sdcard/external_sd", ml, pkg_name);

    File[] ext_dirs = ContextCompat.getExternalFilesDirs(c, null);
    if (ext_dirs != null) {
        for (int i = 0; i < ext_dirs.length; i++) {
            if (ext_dirs[i] != null && ext_dirs[i].getPath() != null) {
                if (!ext_dirs[i].getPath().startsWith(primary_esd)) {
                    boolean found = false;
                    for (int j = 0; j < ml.size(); j++) {
                        if (ext_dirs[i].getPath().equals(ml.get(j))) {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                        ml.add(ext_dirs[i].getPath());
                }
            }
        }
    }

    Collections.sort(ml);
    return ml;
}

From source file:com.licenta.android.licenseapp.alarm.AlarmReceiver.java

public static void cancelAlarm(Context context) {
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(context, AlarmReceiver.class);
    PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);

    //if (alarmManager!= null) {
    alarmManager.cancel(alarmIntent);/*  w  w  w.  j  a v  a 2s. com*/

    PreferenceManager.getDefaultSharedPreferences(context).edit()
            .putBoolean(Constants.PREF_KEY_IS_ALARM_ON, false).apply();
    Log.d(context.getClass().getName(), "Alarm stopped");
    //}
}

From source file:org.opensilk.video.util.Utils.java

public static Activity findActivity(Context context) {
    if (context instanceof Activity) {
        return (Activity) context;
    } else if (context instanceof ContextWrapper) {
        ContextWrapper contextWrapper = (ContextWrapper) context;
        return findActivity(contextWrapper.getBaseContext());
    } else {//  w  w w.  j  av a 2 s  . co m
        throw new AssertionError("Unknown context type " + context.getClass().getName());
    }
}

From source file:Main.java

public static boolean startActivity(Context a, String packageName) {
    PackageManager pm = a.getPackageManager();
    boolean result = true;
    try {//  w  w w  .  j a v  a 2s  .  c  om
        Intent intent = pm.getLaunchIntentForPackage(packageName);
        if (intent != null) {
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            //         intent.addCategory(Intent.CATEGORY_LAUNCHER);
            a.startActivity(intent);
        } else {
            result = startActivityUsingScheme(a, packageName);
        }
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = startActivityUsingScheme(a, packageName);
    }
    return result;
}

From source file:edu.mecc.race2ged.helpers.Utils.java

/**
 * Send an email with supplied address, subject, and content.
 * @param emailAddress To: Email Address
 * @param emailSubject Email Subject/*from   w ww.j  a va 2 s.  c o  m*/
 * @param emailBody Email Body Content
 */
public static void sendEmail(Context context, String emailAddress, String emailSubject, String emailBody) {
    try {
        final Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.setType("plain/html");
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
        emailIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
        context.startActivity(Intent.createChooser(emailIntent, "Select your Email App:"));
    } catch (Exception e) {
        Log.e(context.getClass().getSimpleName(),
                "Error sending email. Email app installed? - " + e.getMessage());
    }
}