Example usage for android.graphics BitmapFactory decodeResource

List of usage examples for android.graphics BitmapFactory decodeResource

Introduction

In this page you can find the example usage for android.graphics BitmapFactory decodeResource.

Prototype

public static Bitmap decodeResource(Resources res, int id) 

Source Link

Document

Synonym for #decodeResource(Resources,int,android.graphics.BitmapFactory.Options) with null Options.

Usage

From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(false);//from   w  w w.  j  ava 2 s.  c om
    //MAIN_ACTIVITY = (MainActivity) getActivity();
    initNoFileLayout();
    SHOW_HIDDEN = sharedPref.getBoolean("showHidden", false);
    COLORISE_ICONS = sharedPref.getBoolean("coloriseIcons", true);
    mFolderBitmap = BitmapFactory.decodeResource(res, R.drawable.ic_grid_folder_new);
    goback = res.getString(R.string.goback);
    folder = new BitmapDrawable(res, mFolderBitmap);
    getSortModes();
    DARK_IMAGE = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.ic_doc_image_dark));
    DARK_VIDEO = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.ic_doc_video_dark));
    this.setRetainInstance(false);
    HFile f = new HFile(OpenMode.UNKNOWN, CURRENT_PATH);
    f.generateMode(getActivity());
    MAIN_ACTIVITY.initiatebbar();
    ic = new IconHolder(getActivity(), SHOW_THUMBS, !IS_LIST);

    if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT) && !IS_LIST) {
        listView.setBackgroundColor(Utils.getColor(getContext(), R.color.grid_background_light));
    } else {
        listView.setBackgroundDrawable(null);
    }

    listView.setHasFixedSize(true);
    columns = Integer.parseInt(sharedPref.getString("columns", "-1"));
    if (IS_LIST) {
        mLayoutManager = new LinearLayoutManager(getActivity());
        listView.setLayoutManager(mLayoutManager);
    } else {
        if (columns == -1 || columns == 0)
            mLayoutManagerGrid = new GridLayoutManager(getActivity(), 3);
        else
            mLayoutManagerGrid = new GridLayoutManager(getActivity(), columns);
        listView.setLayoutManager(mLayoutManagerGrid);
    }
    // use a linear layout manager
    //View footerView = getActivity().getLayoutInflater().inflate(R.layout.divider, null);// TODO: 23/5/2017 use or delete
    dividerItemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false,
            SHOW_DIVIDERS);
    listView.addItemDecoration(dividerItemDecoration);
    mSwipeRefreshLayout.setColorSchemeColors(Color.parseColor(fabSkin));
    DefaultItemAnimator animator = new DefaultItemAnimator();
    listView.setItemAnimator(animator);
    mToolbarContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if ((columns == 0 || columns == -1)) {
                        int screen_width = listView.getWidth();
                        int dptopx = Utils.dpToPx(115, getContext());
                        columns = screen_width / dptopx;
                        if (columns == 0 || columns == -1)
                            columns = 3;
                        if (!IS_LIST)
                            mLayoutManagerGrid.setSpanCount(columns);
                    }
                    if (savedInstanceState != null && !IS_LIST)
                        retrieveFromSavedInstance(savedInstanceState);
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
                        mToolbarContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mToolbarContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }

            });

    if (savedInstanceState == null) {
        loadlist(CURRENT_PATH, false, openMode);
    } else {
        if (IS_LIST)
            retrieveFromSavedInstance(savedInstanceState);
    }
}

From source file:com.android.tv.tuner.setup.TunerSetupActivity.java

private static void sendNotification(Context context, Integer tunerType) {
    SoftPreconditions.checkState(tunerType != null, TAG, "tunerType is null when send notification");
    if (tunerType == null) {
        return;//from w w  w .  j  a  v  a  2s.  c  o  m
    }
    Resources resources = context.getResources();
    String contentTitle = resources.getString(R.string.ut_setup_notification_content_title);
    int contentTextId = 0;
    switch (tunerType) {
    case TunerHal.TUNER_TYPE_BUILT_IN:
        contentTextId = R.string.bt_setup_notification_content_text;
        break;
    case TunerHal.TUNER_TYPE_USB:
        contentTextId = R.string.ut_setup_notification_content_text;
        break;
    case TunerHal.TUNER_TYPE_NETWORK:
        contentTextId = R.string.nt_setup_notification_content_text;
        break;
    }
    String contentText = resources.getString(contentTextId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        sendNotificationInternal(context, contentTitle, contentText);
    } else {
        Bitmap largeIcon = BitmapFactory.decodeResource(resources, R.drawable.recommendation_antenna);
        sendRecommendationCard(context, contentTitle, contentText, largeIcon);
    }
}

From source file:com.nijie.samples.facebookfoo.FacebookFooMainActivity.java

private void postPhoto() {
    Bitmap image = BitmapFactory.decodeResource(this.getResources(), R.drawable.icon);
    if (canPresentShareDialogWithPhotos) {
        FacebookDialog shareDialog = createShareDialogBuilderForPhoto(image).build();
        uiHelper.trackPendingDialogCall(shareDialog.present());
    } else if (hasPublishPermission()) {
        Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), image,
                new Request.Callback() {
                    @Override/*from w  ww.ja va2s .  c  o  m*/
                    public void onCompleted(Response response) {
                        showPublishResult(getString(R.string.photo_post), response.getGraphObject(),
                                response.getError());
                    }
                });
        request.executeAsync();
    } else {
        pendingAction = PendingAction.POST_PHOTO;
    }
}

From source file:zxing.util.CaptureActivity.java

License:asdf

/**
 * A valid barcode has been found, so give an indication of success and show
 * the results./*from   www  .ja  va2 s  . c o  m*/
 * 
 * @param rawResult
 *            The contents of the barcode.
 * @param scaleFactor
 *            amount by which thumbnail was scaled
 * @param barcode
 *            A greyscale bitmap of the camera data which was decoded.
 */
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
    inactivityTimer.onActivity();
    //lastResult = rawResult;
    String url = "http://192.168.1.105:8080/ExTraceWebService_war/REST/Domain";
    beepManager.playBeepSoundAndVibrate();
    String resultString = rawResult.getText();
    Intent mIntent = getIntent();
    if (mIntent.getStringExtra("Action").equals("Pkg")) {
        switch (Integer.parseInt(mIntent.getStringExtra("role").toString().substring(0, 1))) {
        //(
        //
        case 1:
            Log.i("teasdfjsadf", mIntent.getStringExtra("role").toString());
            if (resultString.startsWith("1")) {

                url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/"
                        + mIntent.getStringExtra("role").toString();
                startOnePkgExp(url);//
                //            Intent intentTest=new Intent(this,BaiduActivity.class);
                //            startActivity(intentTest);
                break;
            } else if (resultString.startsWith("8")) {
                url = url + "/dispatchExpressSheetId/id/" + resultString + "/uid/"
                        + mIntent.getStringExtra("role").toString();
                changePkgToStatus4(url);//
                break;
            } else {
                break;
            }
            //
        case 2:
            if (resultString.startsWith("8")) {

                url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/"
                        + mIntent.getStringExtra("role").toString();
                startOnePkgExp(url);//
                //               Intent intentTest=new Intent(this,BaiduActivity.class);
                //               startActivity(intentTest);
                break;
            }

            break;
        //
        case 3:
            if (resultString.startsWith("1")) {
                url = url + "/packTransPackage/PackageID/" + "8001" + "/ExpressID/" + resultString;
                //               Intent intentTest=new Intent(this,BaiduActivity.class);
                //               startActivity(intentTest);
                break;
            } else if (resultString.startsWith("8")) {
                url = url + "/unpackTransPackage/" + resultString + "/uid/"
                        + mIntent.getStringExtra("role").toString();
                break;
            } else {
                break;
            }

        }
    } else if (mIntent.getStringExtra("Action").equals("exp")) {
        //
        switch (Integer.parseInt(mIntent.getStringExtra("role"))) {
        case 1:
            //finsh();
            break;
        case 2:
            if (resultString.startsWith("8")) {
                url = url + "/unpackTransPackage/" + "8001";
                //               Intent intentTest=new Intent(this,BaiduActivity.class);
                //               startActivity(intentTest);
                break;
            } else {

            }
            //finsh();
            break;
        //
        case 3:

        }
    }

    drawResultPoints(barcode, scaleFactor, rawResult);
    statusView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
    if (barcode == null) {
        barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.launcher_icon));
    } else {
        barcodeImageView.setImageBitmap(barcode);
    }

    ParsedResult result = ResultParser.parseResult(rawResult);
    String contents = result.getDisplayResult().replace("\r", "");
    CharSequence displayContents = contents;
    lastResult = contents;
    TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
    contentsTextView.setText(displayContents);
    int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
    contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);
}

From source file:com.mappn.gfan.ui.HomeTabActivity.java

private void drawUpdateCount(Activity context, Resources res, ImageView view, boolean flag) {
    DisplayMetrics dm = new DisplayMetrics();
    context.getWindowManager().getDefaultDisplay().getMetrics(dm);
    Bitmap cornerRes = BitmapFactory.decodeResource(res, R.drawable.notify_update);
    Bitmap appBitmapNormal = BitmapFactory.decodeResource(res, R.drawable.main_tab_app_unselect);
    Bitmap appBitmapPressed = BitmapFactory.decodeResource(res, R.drawable.main_tab_app_select);

    StateListDrawable stateDrawable = new StateListDrawable();
    int stateSelected = android.R.attr.state_selected;
    if (flag) {/* ww w. ja  v  a2 s  .c o m*/
        Bitmap cornerBitmap = drawText(dm, res, cornerRes, mSession.getUpgradeNumber());
        Bitmap newBitmapNormal = drawBitmap(dm, appBitmapNormal, cornerBitmap);
        Bitmap newBitmapPressed = drawBitmap(dm, appBitmapPressed, cornerBitmap);

        stateDrawable.addState(new int[] { -stateSelected }, new BitmapDrawable(res, newBitmapNormal));
        stateDrawable.addState(new int[] { stateSelected }, new BitmapDrawable(res, newBitmapPressed));

        view.setImageDrawable(stateDrawable);
    } else {

        view.setImageResource(R.drawable.main_tab_app_manager_selector);
    }
}

From source file:com.berniesanders.fieldthebern.views.MapScreenView.java

public void setNearbyAddresses(List<ApiAddress> nearbyAddresses) {
    if (nearbyAddresses == null) {
        return;/*from   w ww.j a v a2 s  .  c om*/
    }
    this.nearbyAddresses = nearbyAddresses;
    if (googleMap == null) {
        return;
    }
    googleMap.clear();
    markerAddressMap.clear();

    Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_place_white_24dp);

    for (ApiAddress apiAddress : nearbyAddresses) {

        Double lat = apiAddress.attributes().latitude();
        Double lng = apiAddress.attributes().longitude();

        if (lat != null && lng != null) {
            String lastResponse = apiAddress.attributes().bestCanvassResponse();
            Bitmap icon = colorBitmap(bmp, ResponseColor.getColor(lastResponse, getContext()));

            Marker marker = googleMap
                    .addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(icon))
                            .position(new LatLng(lat, lng)).title(CanvassResponseEvaluator.getText(lastResponse,
                                    getResources().getStringArray(R.array.interest))));

            markerAddressMap.put(marker.getId(), apiAddress);
        }
    }

    googleMap.setOnMarkerClickListener(onMarkerClickListener);
}

From source file:edu.cens.loci.ui.PlaceListActivity.java

public void initIcons() {

    int resId;/*from   w w  w.j  av  a  2s . com*/

    if (mSatIcon == null) {
        resId = getResources().getIdentifier("edu.cens.loci:drawable/icon_satellite", null, null);
        mSatIcon = overlay(BitmapFactory.decodeResource(getResources(), resId));
    }
    if (mWifiIcon == null) {
        resId = getResources().getIdentifier("edu.cens.loci:drawable/icon_wifi", null, null);
        mWifiIcon = overlay(BitmapFactory.decodeResource(getResources(), resId));
    }
    if (mUnknownIcon == null) {
        resId = getResources().getIdentifier("edu.cens.loci:drawable/icon_question", null, null);
        mUnknownIcon = overlay(BitmapFactory.decodeResource(getResources(), resId));
    }
    if (mRegisteredIcon == null) {
        resId = getResources().getIdentifier("edu.cens.loci:drawable/icon_check", null, null);
        mRegisteredIcon = overlay(BitmapFactory.decodeResource(getResources(), resId));
    }
    if (mSuggestedIcon == null) {
        resId = getResources().getIdentifier("edu.cens.loci:drawable/icon_suggest", null, null);
        mSuggestedIcon = overlay(BitmapFactory.decodeResource(getResources(), resId));
    }
    if (mBlockedIcon == null) {
        resId = getResources().getIdentifier("edu.cens.loci:drawable/icon_block", null, null);
        mBlockedIcon = overlay(BitmapFactory.decodeResource(getResources(), resId));
    }
}

From source file:com.adam.aslfms.util.Util.java

public static void myNotify(Context mCtx, String title, String content, int notID) {
    try {//w ww . j  ava 2 s .c om
        Intent targetIntent = new Intent(mCtx, SettingsActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(mCtx, 0, targetIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(mCtx).setContentTitle(title)
                .setSmallIcon(R.mipmap.ic_notify).setContentText(content).setContentIntent(contentIntent);
        NotificationManager nManager = (NotificationManager) mCtx
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
            builder.setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher));
        }
        nManager.notify(notID, builder.build());
    } catch (Exception e) {
        Log.d(TAG, "Phone Notification failed. " + e);
    }
}

From source file:com.cognizant.glass.bluetoothconnect.DemoAppRecieverService.java

/**
 * method handles the Live card notifications
 * /*from  w w w . j  a  va2 s.  c o m*/
 * @param context
 * @param jsonArray
 * 
 *            whenever the user is in background and new message is received
 *            a live card is created and if already present the values are
 *            updated with the current message contents.
 */
private void publishCard(final Context context, final JSONArray jsonArray) {

    if (mLiveCard == null) {
        mLiveCard = new LiveCard(this, LIVE_CARD_TAG);
    }
    livecardView = new RemoteViews(context.getPackageName(), R.layout.activity_second);
    try {
        if (jsonArray.length() > 1) {
            String imageName1 = jsonArray.getJSONObject(0).getString(Constants.TAG_CASETITLE).toLowerCase();
            imageName1 = imageName1.replace(" ", "_");
            String imageName2 = jsonArray.getJSONObject(1).getString(Constants.TAG_CASETITLE).toLowerCase();
            imageName2 = imageName2.replace(" ", "_");
            livecardView.setTextViewText(R.id.text,
                    jsonArray.getJSONObject(0).getString(Constants.TAG_CASETITLE));
            livecardView.setTextViewText(R.id.livecard_ticketNo,
                    jsonArray.getJSONObject(0).getString(Constants.TAG_TICKETCOUNT) + " ticket(s)");
            livecardView.setTextViewText(R.id.text2,
                    jsonArray.getJSONObject(1).getString(Constants.TAG_CASETITLE));
            livecardView.setTextViewText(R.id.livecard_ticketNo2,
                    jsonArray.getJSONObject(1).getString(Constants.TAG_TICKETCOUNT) + " ticket(s)");
            try {
                String fnm = imageName1; // this is image
                // file name
                final String image2 = imageName2;
                String packageName = getApplicationContext().getPackageName();
                final int imgId = getResources().getIdentifier(packageName + ":drawable/" + fnm, null, null);
                final int imgId2 = getResources().getIdentifier(packageName + ":drawable/" + image2, null,
                        null);
                livecardView.setImageViewBitmap(R.id.image1_livecard,
                        BitmapFactory.decodeResource(getResources(), imgId));
                livecardView.setImageViewBitmap(R.id.image2_livecard,
                        BitmapFactory.decodeResource(getResources(), imgId2));
            } catch (Exception e) {
                e.printStackTrace();
            }
            mLiveCard.setViews(livecardView);

        } else {
            livecardView.setTextViewText(R.id.text,
                    jsonArray.getJSONObject(0).getString(Constants.TAG_CASETITLE));
            livecardView.setTextViewText(R.id.livecard_ticketNo,
                    jsonArray.getJSONObject(0).getString(Constants.TAG_TICKETCOUNT) + " ticket(s)");
            livecardView.setTextViewText(R.id.text2, "");
            livecardView.setTextViewText(R.id.livecard_ticketNo2, "");
            mLiveCard.setViews(livecardView);

        }

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // pending intent so that when user clicks the live card the
    // corresponding application is opened.
    Intent intent = new Intent(context, MainLauncherActivity.class);
    mLiveCard.setAction(PendingIntent.getActivity(context, 0, intent, 0));
    if (!mLiveCard.isPublished()) {
        mLiveCard.publish(LiveCard.PublishMode.SILENT);
    } else {
        mLiveCard.setViews(livecardView);
    }
}

From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context = this;

    isTablet = Utils.isTablet(this);

    // Setting the default network
    sharedPreferences = getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE);
    Editor editor = sharedPreferences.edit();
    editor.putString(Constants.NETWORK, Constants.DEFAULT_NETWORK);
    editor.commit();/*from ww w. j  av  a 2  s . co m*/

    // Starting the resources monitoring service
    startService(new Intent(this, DeviceMonitorService.class));

    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    // Settings menu elements
    ArrayList<MenuListElement> listElements = new ArrayList<MenuListElement>();

    listElements.add(new MenuListElement(getResources().getString(R.string.connectMenuTitle),
            getResources().getString(R.string.connectMenuSubTitle)));
    listElements.add(new MenuListElement(getResources().getString(R.string.settingsMenuTitle),
            getResources().getString(R.string.settingsMenuSubTitle)));
    listElements.add(new MenuListElement(getResources().getString(R.string.exitMenuTitle),
            getResources().getString(R.string.exitMenuSubTitle)));

    listView = (ListView) findViewById(R.id.ListViewContent);

    MenuListAdapter adapter = new MenuListAdapter(this, R.layout.menu_list_view_row, listElements);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new ListItemClickListener());

    mainRL = (RelativeLayout) findViewById(R.id.rlContainer);
    listRL = (RelativeLayout) findViewById(R.id.listContainer);

    cpuBar = (LinearLayout) findViewById(R.id.CpuBar);
    memoryBar = (LinearLayout) findViewById(R.id.MemoryBar);

    titleBarRL = (RelativeLayout) findViewById(R.id.titleLl);

    // Adding swipe gesture listener to the top bar
    titleBarRL.setOnTouchListener(new SwipeAndClickListener());

    menuButton = (Button) findViewById(R.id.menuButton);
    menuButton.setOnTouchListener(new SwipeAndClickListener());

    infoButton = (Button) findViewById(R.id.infoButton);
    infoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AlertDialog dialog = new AlertDialog(NAM4JAndroidActivity.this) {

                @Override
                public boolean dispatchTouchEvent(MotionEvent event) {
                    dismiss();
                    return false;
                }

            };

            String text = getResources().getString(R.string.aboutApp);
            String title = getResources().getString(R.string.nam4j);

            dialog.setMessage(text);
            dialog.setTitle(title);
            dialog.setCanceledOnTouchOutside(true);
            dialog.show();
        }
    });

    centerButton = (Button) findViewById(R.id.centerButton);
    centerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            centerMap();
        }
    });

    isTablet = Utils.isTablet(context);

    int[] screenSize = Utils.getScreenSize(context, getWindow());
    screenWidth = screenSize[0];
    screenHeight = screenSize[1];

    // Updates the display orientation each time the device is rotated
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        screenOrientation = Orientation.LANDSCAPE;
    } else {
        screenOrientation = Orientation.PORTRAIT;
    }

    // If the device is portrait, the menu button is displayed, the menu is
    // hidden and the swipe listener is added to the menu bar
    if (screenOrientation == Orientation.PORTRAIT) {

        menuButton.setVisibility(View.VISIBLE);

        // Adding swipe gesture listener to the top bar
        titleBarRL.setOnTouchListener(new SwipeAndClickListener());

        if (isTablet) {
            menuWidth = 0.35;
        } else {
            menuWidth = 0.6;
        }
    } else {
        // If the device is a tablet in landscape, the menu button is
        // hidden, the menu is displayed, the swipe listener is not added to
        // the menu bar and the mainRL width is set to the window's width
        // minus the menu's width
        if (isTablet) {
            menuWidth = 0.2;
            menuButton.setVisibility(View.INVISIBLE);

            RelativeLayout.LayoutParams menuListLP = (LayoutParams) mainRL.getLayoutParams();

            // Setting the main view width as the container width without
            // the menu
            menuListLP.width = (int) (screenWidth * (1 - menuWidth));
            mainRL.setLayoutParams(menuListLP);

            displaySideMenu();
        } else {
            menuWidth = 0.4;
            menuButton.setVisibility(View.VISIBLE);

            // Adding swipe gesture listener to the top bar
            titleBarRL.setOnTouchListener(new SwipeAndClickListener());
        }
    }

    // Check if the device has the Google Play Services installed and
    // updated. They are necessary to use Google Maps
    int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);

    if (code != ConnectionResult.SUCCESS) {

        showErrorDialog(code);

        System.out.println("Google Play Services error");

        FrameLayout fl = (FrameLayout) findViewById(R.id.frameId);
        fl.removeAllViews();
    } else {
        // Create a new global location parameters object
        mLocationRequest = new LocationRequest();

        // Set the update interval
        mLocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);

        // Use high accuracy
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        // Set the interval ceiling to one minute
        mLocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);

        bitmapDescriptorBlue = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);

        blueCircle = BitmapDescriptorFactory
                .fromBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.blue_circle));

        bitmapDescriptorRed = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED);

        // Create a new location client, using the enclosing class to handle
        // callbacks
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(LocationServices.API).build();

        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapview)).getMap();

        if (map != null) {

            // Set default map center and zoom on Parma
            double lat = 44.7950156;
            double lgt = 10.32547;
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lgt), 12.0f));

            // Adding listeners to the map respectively for zoom level
            // change and onTap event
            map.setOnCameraChangeListener(getCameraChangeListener());
            map.setOnMapClickListener(getOnMapClickListener());

            // Set map type as normal (i.e. not the satellite view)
            map.setMapType(com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL);

            // Hide traffic layer
            map.setTrafficEnabled(false);

            // Enable the 'my-location' layer, which continuously draws an
            // indication of a user's current location and bearing, and
            // displays UI controls that allow the interaction with the
            // location itself
            // map.setMyLocationEnabled(true);

            ml = new HashMap<String, Marker>();

            // Get file manager for config files
            fileManager = FileManager.getFileManager();
            fileManager.createFiles();

            map.setOnMarkerClickListener(this);

        } else {
            AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            dialog.setMessage("The map cannot be initialized.");
            dialog.setCancelable(true);
            dialog.setPositiveButton(getResources().getString(R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.dismiss();
                        }
                    });
            dialog.show();
        }
    }
}