Example usage for android.content Intent getStringExtra

List of usage examples for android.content Intent getStringExtra

Introduction

In this page you can find the example usage for android.content Intent getStringExtra.

Prototype

public String getStringExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:key.secretkey.crypto.PgpHandler.java

private void selectFolder(Intent data) {

    if (data.getStringExtra("Operation") == null || !data.getStringExtra("Operation").equals("SELECTFOLDER")) {
        Log.e(Constants.TAG, "PgpHandler#selectFolder(Intent) triggered with incorrect intent.");
        if (BuildConfig.DEBUG) {
            throw new UnsupportedOperationException("Triggered with incorrect intent.");
        }/*from www  . j  a v a2 s  .c om*/
        return;
    }

    Log.d(Constants.TAG, "PgpHandler#selectFolder(Intent).");

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    passwordList = new SelectFolderFragment();
    Bundle args = new Bundle();
    //        args.putString("Path", PasswordStorage.getRepositoryDirectory(getApplicationContext()).getAbsolutePath());

    passwordList.setArguments(args);

    getSupportActionBar().show();

    fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);

    fragmentTransaction.replace(R.id.pgp_handler_linearlayout, passwordList, "PasswordsList");
    fragmentTransaction.commit();

    this.selectFolderData = data;
}

From source file:com.concentricsky.android.khanacademy.app.ShowProfileActivity.java

private void handleLoginResult(int resultCode, Intent intent) {
    Log.d(LOG_TAG, "request code was user login, result code is " + resultCode);
    if (destroyed)
        return;//from w w  w.j a  v  a 2 s . c o m

    // Sent by SignInActivity
    switch (resultCode) {
    case Constants.RESULT_CODE_SUCCESS:
        String token = intent == null ? null : intent.getStringExtra(Constants.PARAM_OAUTH_TOKEN);
        String secret = intent == null ? null : intent.getStringExtra(Constants.PARAM_OAUTH_SECRET);

        loginUser(token, secret);

        break;
    case Constants.RESULT_CODE_FAILURE:
        // Network error, user declines authorization, activity closed before finishing.
        Toast.makeText(this, "Login failed", Toast.LENGTH_SHORT).show();
        // fall through
    default:
        // User exits the login dialog without finishing the process.
        finish();
    }

}

From source file:com.hhunj.hhudata.SearchBookContentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();
    if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) {
        finish();/*from   w w w .j a  v a  2  s .  c  o m*/
        return;
    }

    //pageid,pagenumber
    //ISBN  ---stationid,
    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);//stationid
    if (isbn.startsWith("http://google.com/books?id=")) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && initialQuery.length() > 0) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:ie.programmer.catcher.AppLinkTest.java

public void testGeneralMeasurementEventsBroadcast() throws Exception {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
    i.putExtra("foo", "bar");
    ArrayList<String> arr = new ArrayList<>();
    arr.add("foo2");
    arr.add("bar2");
    i.putExtra("foobar", arr);
    Map<String, String> other = new HashMap<>();
    other.put("yetAnotherFoo", "yetAnotherBar");

    final CountDownLatch lock = new CountDownLatch(1);
    final String[] receivedStrings = new String[5];
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext());
    manager.registerReceiver(new BroadcastReceiver() {
        @Override// w  w w .j  a v  a2s  .c  o m
        public void onReceive(Context context, Intent intent) {
            String eventName = intent.getStringExtra("event_name");
            Bundle eventArgs = intent.getBundleExtra("event_args");
            receivedStrings[0] = eventName;
            receivedStrings[1] = eventArgs.getString("foo");
            receivedStrings[2] = eventArgs.getString("foobar");
            receivedStrings[3] = eventArgs.getString("yetAnotherFoo");
            receivedStrings[4] = eventArgs.getString("intentData");
            lock.countDown();
        }
    }, new IntentFilter("com.parse.bolts.measurement_event"));

    //    MeasurementEvent.sendBroadcastEvent(getInstrumentation().getTargetContext(), "myEventName", i, other);
    lock.await(2000, TimeUnit.MILLISECONDS);

    assertEquals("myEventName", receivedStrings[0]);
    assertEquals("bar", receivedStrings[1]);
    assertEquals((new JSONArray(arr)).toString(), receivedStrings[2]);
    assertEquals("yetAnotherBar", receivedStrings[3]);
    assertEquals("http://www.example.com", receivedStrings[4]);
}

From source file:it.feio.android.omninotes.async.DataBackupIntentService.java

/**
  * Imports notes and notebooks from Springpad exported archive
  *// ww  w. j  a v  a2s.  c o  m
  * @param intent
  */
synchronized private void importDataFromSpringpad(Intent intent) {
    String backupPath = intent.getStringExtra(EXTRA_SPRINGPAD_BACKUP);
    Importer importer = new Importer();
    try {
        importer.setZipProgressesListener(percentage -> mNotificationsHelper
                .setMessage(getString(R.string.extracted) + " " + percentage + "%").show());
        importer.doImport(backupPath);
        // Updating notification
        updateImportNotification(importer);
    } catch (ImportException e) {
        new NotificationsHelper(this).createNotification(R.drawable.ic_emoticon_sad_white_24dp,
                getString(R.string.import_fail) + ": " + e.getMessage(), null).setLedActive().show();
        return;
    }
    List<SpringpadElement> elements = importer.getSpringpadNotes();

    // If nothing is retrieved it will exit
    if (elements == null || elements.size() == 0) {
        return;
    }

    // These maps are used to associate with post processing notes to categories (notebooks)
    HashMap<String, Category> categoriesWithUuid = new HashMap<>();

    // Adds all the notebooks (categories)
    for (SpringpadElement springpadElement : importer.getNotebooks()) {
        Category cat = new Category();
        cat.setName(springpadElement.getName());
        cat.setColor(String.valueOf(Color.parseColor("#F9EA1B")));
        DbHelper.getInstance().updateCategory(cat);
        categoriesWithUuid.put(springpadElement.getUuid(), cat);

        // Updating notification
        importedSpringpadNotebooks++;
        updateImportNotification(importer);
    }
    // And creates a default one for notes without notebook 
    Category defaulCategory = new Category();
    defaulCategory.setName("Springpad");
    defaulCategory.setColor(String.valueOf(Color.parseColor("#F9EA1B")));
    DbHelper.getInstance().updateCategory(defaulCategory);

    // And then notes are created
    Note note;
    Attachment mAttachment = null;
    Uri uri;
    for (SpringpadElement springpadElement : importer.getNotes()) {
        note = new Note();

        // Title
        note.setTitle(springpadElement.getName());

        // Content dependent from type of Springpad note
        StringBuilder content = new StringBuilder();
        content.append(
                TextUtils.isEmpty(springpadElement.getText()) ? "" : Html.fromHtml(springpadElement.getText()));
        content.append(
                TextUtils.isEmpty(springpadElement.getDescription()) ? "" : springpadElement.getDescription());

        // Some notes could have been exported wrongly
        if (springpadElement.getType() == null) {
            Toast.makeText(this, getString(R.string.error), Toast.LENGTH_SHORT).show();
            continue;
        }

        if (springpadElement.getType().equals(SpringpadElement.TYPE_VIDEO)) {
            try {
                content.append(System.getProperty("line.separator"))
                        .append(springpadElement.getVideos().get(0));
            } catch (IndexOutOfBoundsException e) {
                content.append(System.getProperty("line.separator")).append(springpadElement.getUrl());
            }
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_TVSHOW)) {
            content.append(System.getProperty("line.separator"))
                    .append(TextUtils.join(", ", springpadElement.getCast()));
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOK)) {
            content.append(System.getProperty("line.separator")).append("Author: ")
                    .append(springpadElement.getAuthor()).append(System.getProperty("line.separator"))
                    .append("Publication date: ").append(springpadElement.getPublicationDate());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_RECIPE)) {
            content.append(System.getProperty("line.separator")).append("Ingredients: ")
                    .append(springpadElement.getIngredients()).append(System.getProperty("line.separator"))
                    .append("Directions: ").append(springpadElement.getDirections());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOKMARK)) {
            content.append(System.getProperty("line.separator")).append(springpadElement.getUrl());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_BUSINESS)
                && springpadElement.getPhoneNumbers() != null) {
            content.append(System.getProperty("line.separator")).append("Phone number: ")
                    .append(springpadElement.getPhoneNumbers().getPhone());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_PRODUCT)) {
            content.append(System.getProperty("line.separator")).append("Category: ")
                    .append(springpadElement.getCategory()).append(System.getProperty("line.separator"))
                    .append("Manufacturer: ").append(springpadElement.getManufacturer())
                    .append(System.getProperty("line.separator")).append("Price: ")
                    .append(springpadElement.getPrice());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_WINE)) {
            content.append(System.getProperty("line.separator")).append("Wine type: ")
                    .append(springpadElement.getWine_type()).append(System.getProperty("line.separator"))
                    .append("Varietal: ").append(springpadElement.getVarietal())
                    .append(System.getProperty("line.separator")).append("Price: ")
                    .append(springpadElement.getPrice());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_ALBUM)) {
            content.append(System.getProperty("line.separator")).append("Artist: ")
                    .append(springpadElement.getArtist());
        }
        for (SpringpadComment springpadComment : springpadElement.getComments()) {
            content.append(System.getProperty("line.separator")).append(springpadComment.getCommenter())
                    .append(" commented at 0").append(springpadComment.getDate()).append(": ")
                    .append(springpadElement.getArtist());
        }

        note.setContent(content.toString());

        // Checklists
        if (springpadElement.getType().equals(SpringpadElement.TYPE_CHECKLIST)) {
            StringBuilder sb = new StringBuilder();
            String checkmark;
            for (SpringpadItem mSpringpadItem : springpadElement.getItems()) {
                checkmark = mSpringpadItem.getComplete()
                        ? it.feio.android.checklistview.interfaces.Constants.CHECKED_SYM
                        : it.feio.android.checklistview.interfaces.Constants.UNCHECKED_SYM;
                sb.append(checkmark).append(mSpringpadItem.getName())
                        .append(System.getProperty("line.separator"));
            }
            note.setContent(sb.toString());
            note.setChecklist(true);
        }

        // Tags
        String tags = springpadElement.getTags().size() > 0
                ? "#" + TextUtils.join(" #", springpadElement.getTags())
                : "";
        if (note.isChecklist()) {
            note.setTitle(note.getTitle() + tags);
        } else {
            note.setContent(note.getContent() + System.getProperty("line.separator") + tags);
        }

        // Address
        String address = springpadElement.getAddresses() != null ? springpadElement.getAddresses().getAddress()
                : "";
        if (!TextUtils.isEmpty(address)) {
            try {
                double[] coords = GeocodeHelper.getCoordinatesFromAddress(this, address);
                note.setLatitude(coords[0]);
                note.setLongitude(coords[1]);
            } catch (IOException e) {
                Log.e(Constants.TAG,
                        "An error occurred trying to resolve address to coords during Springpad import");
            }
            note.setAddress(address);
        }

        // Reminder
        if (springpadElement.getDate() != null) {
            note.setAlarm(springpadElement.getDate().getTime());
        }

        // Creation, modification, category
        note.setCreation(springpadElement.getCreated().getTime());
        note.setLastModification(springpadElement.getModified().getTime());

        // Image
        String image = springpadElement.getImage();
        if (!TextUtils.isEmpty(image)) {
            try {
                File file = StorageHelper.createNewAttachmentFileFromHttp(this, image);
                uri = Uri.fromFile(file);
                String mimeType = StorageHelper.getMimeType(uri.getPath());
                mAttachment = new Attachment(uri, mimeType);
            } catch (MalformedURLException e) {
                uri = Uri.parse(importer.getWorkingPath() + image);
                mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true);
            } catch (IOException e) {
                Log.e(Constants.TAG, "Error retrieving Springpad online image");
            }
            if (mAttachment != null) {
                note.addAttachment(mAttachment);
            }
            mAttachment = null;
        }

        // Other attachments
        for (SpringpadAttachment springpadAttachment : springpadElement.getAttachments()) {
            // The attachment could be the image itself so it's jumped
            if (image != null && image.equals(springpadAttachment.getUrl()))
                continue;

            if (TextUtils.isEmpty(springpadAttachment.getUrl())) {
                continue;
            }

            // Tries first with online images
            try {
                File file = StorageHelper.createNewAttachmentFileFromHttp(this, springpadAttachment.getUrl());
                uri = Uri.fromFile(file);
                String mimeType = StorageHelper.getMimeType(uri.getPath());
                mAttachment = new Attachment(uri, mimeType);
            } catch (MalformedURLException e) {
                uri = Uri.parse(importer.getWorkingPath() + springpadAttachment.getUrl());
                mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true);
            } catch (IOException e) {
                Log.e(Constants.TAG, "Error retrieving Springpad online image");
            }
            if (mAttachment != null) {
                note.addAttachment(mAttachment);
            }
            mAttachment = null;
        }

        // If the note has a category is added to the map to be post-processed
        if (springpadElement.getNotebooks().size() > 0) {
            note.setCategory(categoriesWithUuid.get(springpadElement.getNotebooks().get(0)));
        } else {
            note.setCategory(defaulCategory);
        }

        // The note is saved
        DbHelper.getInstance().updateNote(note, false);
        ReminderHelper.addReminder(OmniNotes.getAppContext(), note);

        // Updating notification
        importedSpringpadNotes++;
        updateImportNotification(importer);
    }

    // Delete temp data
    try {
        importer.clean();
    } catch (IOException e) {
        Log.w(Constants.TAG, "Springpad import temp files not deleted");
    }

    String title = getString(R.string.data_import_completed);
    String text = getString(R.string.click_to_refresh_application);
    createNotification(intent, this, title, text, null);
}

From source file:bolts.AppLinkTest.java

public void testAppLinkNavInEventBroadcast() throws Exception {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
    Bundle appLinkData = new Bundle();
    appLinkData.putString("target_url", "http://www.example2.com");
    Bundle appLinkRefererData = new Bundle();
    appLinkRefererData.putString("url", "referer://");
    appLinkRefererData.putString("app_name", "Referrer App");
    appLinkRefererData.putString("package", "com.bolts.referrer");
    appLinkData.putBundle("referer_app_link", appLinkRefererData);
    Bundle applinkExtras = new Bundle();
    applinkExtras.putString("token", "a_token");
    appLinkData.putBundle("extras", applinkExtras);
    i.putExtra("al_applink_data", appLinkData);

    final CountDownLatch lock = new CountDownLatch(1);
    final String[] receivedStrings = new String[7];
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext());
    manager.registerReceiver(new BroadcastReceiver() {
        @Override/*  ww w  .  jav a  2 s .  c  o m*/
        public void onReceive(Context context, Intent intent) {
            String eventName = intent.getStringExtra("event_name");
            Bundle eventArgs = intent.getBundleExtra("event_args");
            receivedStrings[0] = eventName;
            receivedStrings[1] = eventArgs.getString("targetURL");
            receivedStrings[2] = eventArgs.getString("inputURL");
            receivedStrings[3] = eventArgs.getString("refererURL");
            receivedStrings[4] = eventArgs.getString("refererAppName");
            receivedStrings[5] = eventArgs.getString("extras/token");
            receivedStrings[6] = eventArgs.getString("sourceApplication");
            lock.countDown();
        }
    }, new IntentFilter("com.parse.bolts.measurement_event"));

    Uri targetUrl = AppLinks.getTargetUrlFromInboundIntent(getInstrumentation().getTargetContext(), i);
    lock.await(2000, TimeUnit.MILLISECONDS);

    assertEquals("al_nav_in", receivedStrings[0]);
    assertEquals("http://www.example2.com", receivedStrings[1]);
    assertEquals("http://www.example.com", receivedStrings[2]);
    assertEquals("referer://", receivedStrings[3]);
    assertEquals("Referrer App", receivedStrings[4]);
    assertEquals("a_token", receivedStrings[5]);
    assertEquals("com.bolts.referrer", receivedStrings[6]);
}

From source file:com.examples.gg.twitchplayers.MediaBuffer.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (!LibsChecker.checkVitamioLibs(this))
        return;//from  ww  w. j  a  v a  2s  .c o m
    setContentView(R.layout.videobuffer2);
    mPreview = (VideoView) findViewById(R.id.buffer);
    mPreview.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
    //      holder = mPreview.getHolder();
    //      holder.addCallback(this);
    //      holder.setFormat(PixelFormat.RGBA_8888); 

    //      mVideoView = (VideoView) findViewById(R.id.buffer);
    qualityView = (ImageView) findViewById(R.id.qualitySwitch);
    mMsgView = (TextView) findViewById(R.id.load_msg);
    pb = (ProgressBar) findViewById(R.id.probar);

    downloadRateView = (TextView) findViewById(R.id.download_rate);
    loadRateView = (TextView) findViewById(R.id.load_rate);

    mInfoListener = this;
    mBufferListener = this;

    // Initialize variables
    globalPath = null;
    responseString = null;
    videoSources = new ArrayList<String>();

    mContext = this;

    // Getting the prefs
    // prefs = this.getSharedPreferences("com.examples.gg",
    // Context.MODE_PRIVATE);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    Intent intent = getIntent();
    channelName = intent.getStringExtra("video");
    // try {
    // popup = new PopupMenu(VideoBuffer.this, qualityView);
    // } catch (Exception e) {
    // }

    // Getting twitch sources
    try {
        channelName = URLEncoder.encode(channelName.toLowerCase(Locale.ENGLISH), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // new MyAsyncTask().execute("http://usher.twitch.tv/select/"
    // + channelName + ".json?nauthsig=&nauth=&allow_source=true");
    String token_api = String.format("http://api.twitch.tv/api/channels/%s/access_token",
            new Object[] { channelName });
    new MyAsyncTask().execute(token_api);

    mMsgView.setText("Loading channel data...");
}

From source file:fi.iki.murgo.irssinotifier.IrssiNotifierActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "Startup");
    super.onCreate(savedInstanceState);

    preferences = new Preferences(this);

    int versionCode = 0;
    try {// w  w w .j  a  v a  2  s.  co m
        versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    if (preferences.isThemeDisabled()) {
        setTheme(R.style.Theme_LameIrssiTheme);
    }

    MessageToServer.setVersion(versionCode);
    Preferences.setVersion(versionCode);

    // do initial settings
    if (preferences.getAccountName() == null || preferences.getGcmRegistrationId() == null
            || preferences.getGcmRegistrationIdVersion() != versionCode
            || (LicenseHelper.isPlusVersion(this) && preferences.getLicenseCount() == 0)) {
        Log.d(TAG, "Asking for initial settings");
        Intent i = new Intent(this, InitialSettingsActivity.class);
        startActivity(i);
        finish();
        return;
    }

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setIndeterminateProgressBarVisibility(false);

    Intent i = getIntent();
    if (i != null) {
        String intentChannelToView = i.getStringExtra("Channel");
        if (intentChannelToView != null && !preferences.isFeedViewDefault())
            channelToView = intentChannelToView;
    }

    boolean b = false;
    if (savedInstanceState != null) {
        b = savedInstanceState.getBoolean("rotated", false);
        channelToView = savedInstanceState.getString("channelToView");
    }

    IrcNotificationManager.getInstance().mainActivityOpened(this);
    startMainApp(b);
}

From source file:it.mb.whatshare.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == QR_CODE_SCANNED) {
        if (resultCode == RESULT_OK) {
            String result = data.getStringExtra("SCAN_RESULT");
            try {
                String[] keys = result.split(" ");

                if (keys.length < SHARED_SECRET_SIZE)
                    throw new NumberFormatException();

                int[] sharedSecret = new int[SHARED_SECRET_SIZE];
                for (int i = 0; i < SHARED_SECRET_SIZE; i++) {
                    sharedSecret[i] = Integer.valueOf(keys[i]);
                }/*  w  w  w  .  j a v  a 2 s  . c  o m*/

                String space = "";
                StringBuilder deviceName = new StringBuilder();
                for (int i = SHARED_SECRET_SIZE; i < keys.length; i++) {
                    deviceName.append(space);
                    deviceName.append(keys[i]);
                    space = " ";
                }

                tracker.sendEvent("qr", "result", "scan_ok", 0L);
                Dialogs.promptForInboundName(deviceName.toString(), sharedSecret, this);
            } catch (NumberFormatException e) {
                tracker.sendEvent("qr", "result", "scan_fail", 0L);
                Dialogs.onQRFail(this);
            }
        } else if (resultCode == RESULT_CANCELED) {
            tracker.sendEvent("qr", "result", "scan_canceled", 0L);
        }
    }
}

From source file:com.timemachine.controller.ControllerActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String input = intent.getStringExtra(SearchManager.QUERY);
        String suggestion = (String) intent.getExtras().get("intent_extra_data_key");
        String query;//  w ww.j  a va  2  s. c  o  m
        // Use the query to search your data somehow
        if (suggestion == null)
            query = input;
        else
            query = suggestion;
        Geocoder geocoder = new Geocoder(ControllerActivity.this);
        try {
            List<Address> address = geocoder.getFromLocationName(query, 1);
            if (address != null && !address.isEmpty()) {
                Address location = address.get(0);
                System.out.println(location.getLatitude() + ", " + location.getLongitude());
                mMap.animateCamera(
                        CameraUpdateFactory.newLatLngZoom(
                                new LatLng(location.getLatitude(), location.getLongitude()), maxZoom),
                        animateCameraDuration, null);
            } else
                System.out.println("No address found.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}