List of usage examples for android.content Intent getStringArrayExtra
public String[] getStringArrayExtra(String name)
From source file:org.elasticdroid.SshConnectorView.java
/** * Called when activity is created.//from w w w .ja v a 2s . c o m * @param savedInstanceState if any */ @SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //call superclass onCreate Intent intent = this.getIntent(); //get all of the data stored in the intent try { this.connectionData = (HashMap<String, String>) intent .getSerializableExtra("org.elasticdroid.EC2DashboardView.connectionData"); } catch (Exception exception) { //the possible exceptions are NullPointerException: the Hashmap was not found, or //ClassCastException: the argument passed is not Hashmap<String, String>. In either case, //just print out the error and exit. This is very inelegant, but this is a programmer's bug Log.e(TAG, exception.getMessage()); finish(); //this will cause it to return to {@link EC2DisplayInstancesView}. } securityGroupNames = intent.getStringArrayExtra("securityGroups"); hostname = intent.getStringExtra("hostname"); selectedRegion = intent.getStringExtra("selectedRegion"); // create and initialise the alert dialog alertDialogBox = new AlertDialog.Builder(this).create(); // create alert alertDialogBox.setCancelable(false); alertDialogBox.setButton(this.getString(R.string.loginview_alertdialogbox_button), new DialogInterface.OnClickListener() { // click listener on the alert box - unlock orientation when // clicked. // this is to prevent orientation changing when alert box // locked. public void onClick(DialogInterface arg0, int arg1) { alertDialogDisplayed = false; alertDialogBox.dismiss(); // dismiss dialog. // if an error occurs that is serious enough return the // user to the login // screen. THis happens due to exceptions caused by // programming errors and // exceptions caused due to invalid credentials. if (killActivityOnError) { Log.v(TAG, "Ich bin hier."); SshConnectorView.this.finish(); } } }); //initialise the display setContentView(R.layout.sshconnector); //tell the activity to set the xml file this.setTitle(connectionData.get("username") + " (" + selectedRegion + ")"); //set title View loginButton = (View) this.findViewById(R.id.sshConnectorLoginButton); loginButton.setOnClickListener(this); }
From source file:com.linkbubble.MainService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { String cmd = intent != null ? intent.getStringExtra("cmd") : null; CrashTracking.log("MainService.onStartCommand(), cmd:" + cmd); MainController mainController = MainController.get(); if (mainController == null || intent == null || cmd == null) { stopSelf();//from w w w. j a va 2 s . c o m return START_NOT_STICKY; } long urlLoadStartTime = intent.getLongExtra("start_time", System.currentTimeMillis()); if (cmd.compareTo("open") == 0) { String url = intent.getStringExtra("url"); if (url != null) { String openedFromAppName = intent.getStringExtra("openedFromAppName"); mainController.openUrl(url, urlLoadStartTime, true, openedFromAppName); } } else if (cmd.compareTo("restore") == 0) { if (!mRestoreComplete) { String[] urls = intent.getStringArrayExtra("urls"); if (urls != null) { int startOpenTabCount = mainController.getActiveTabCount(); for (int i = 0; i < urls.length; i++) { String urlAsString = urls[i]; if (urlAsString != null && !urlAsString.equals(Constant.WELCOME_MESSAGE_URL)) { boolean setAsCurrentTab = false; if (startOpenTabCount == 0) { setAsCurrentTab = i == urls.length - 1; } mainController.openUrl(urlAsString, urlLoadStartTime, setAsCurrentTab, Analytics.OPENED_URL_FROM_RESTORE); } } } mRestoreComplete = true; } } return START_STICKY; }
From source file:org.kontalk.service.UploadService.java
@Override protected void onHandleIntent(Intent intent) { // crappy firmware - as per docs, intent can't be null in this case if (intent == null) return;/*from ww w . ja v a 2 s .c o m*/ // check for unknown action if (!ACTION_UPLOAD.equals(intent.getAction())) return; // local file to upload Uri file = intent.getData(); String filename = file.toString(); // message database id long databaseId = intent.getLongExtra(EXTRA_DATABASE_ID, 0); // message id String msgId = intent.getStringExtra(EXTRA_MESSAGE_ID); // url to post to String url = intent.getStringExtra(EXTRA_POST_URL); // url to fetch from (will be requested to the connection if null) String fetchUrl = intent.getStringExtra(EXTRA_GET_URL); // group JID String groupJid = intent.getStringExtra(EXTRA_GROUP); // user(s) to send message to String[] to; if (groupJid != null) { to = intent.getStringArrayExtra(EXTRA_USER); } else { to = new String[] { intent.getStringExtra(EXTRA_USER) }; } // media mime type String mime = intent.getStringExtra(EXTRA_MIME); // preview file path String previewPath = intent.getStringExtra(EXTRA_PREVIEW_PATH); // encryption flag boolean encrypt = intent.getBooleanExtra(EXTRA_ENCRYPT, false); // delete original boolean deleteOriginal = intent.getBooleanExtra(EXTRA_DELETE_ORIGINAL, false); // check if upload has already been queued if (queue.get(filename) != null) return; try { // notify user about upload immediately long length = MediaStorage.getLength(this, file); Log.v(TAG, "file size is " + length + " bytes"); mTotalBytes = length; startForeground(0); mCanceled = false; // TODO used class here should be decided by the caller mConn = new HTPPFileUploadConnection(this, url); mMessageId = databaseId; queue.put(filename, mMessageId); // upload content String mediaUrl = mConn.upload(file, length, mime, encrypt, to, this); if (mediaUrl == null) mediaUrl = fetchUrl; Log.d(TAG, "uploaded with media URL: " + mediaUrl); // update message fetch_url MessagesProvider.uploaded(this, databaseId, mediaUrl); // send message with fetch url to server if (groupJid != null) { MessageCenterService.sendGroupUploadedMedia(this, groupJid, to, mime, file, length, previewPath, mediaUrl, encrypt, databaseId, msgId); } else { MessageCenterService.sendUploadedMedia(this, to[0], mime, file, length, previewPath, mediaUrl, encrypt, databaseId, msgId); } // end operations completed(); } catch (Exception e) { error(url, null, e); } finally { // only file uri are supported for delete if (deleteOriginal && "file".equals(file.getScheme())) new File(file.getPath()).delete(); queue.remove(filename); mMessageId = 0; } }
From source file:com.geecko.QuickLyric.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { IMMLeaks.fixFocusedViewLeak(getApplication()); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red, R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark }; themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0")); boolean nightMode = sharedPref.getBoolean("pref_night_mode", false); if (nightMode && NightTimeVerifier.check(this)) setTheme(R.style.Theme_QuickLyric_Night); else/* w w w . ja v a 2 s .c om*/ setTheme(themes[themeNum]); super.onCreate(savedInstanceState); setStatusBarColor(null); setNavBarColor(null); final FragmentManager fragmentManager = getFragmentManager(); setContentView(layout.nav_drawer_activity); setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(id.toolbar)); getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setTitle(string.app_name); AppBarLayout appBarLayout = (AppBarLayout) findViewById(id.appbar); appBarLayout.addOnOffsetChangedListener(this); /** Drawer setup */ final ListView drawerList = (ListView) findViewById(id.drawer_list); DrawerAdapter drawerAdapter = new DrawerAdapter(this, this.getResources().getStringArray(array.nav_items)); drawerList.setAdapter(drawerAdapter); drawerView = this.findViewById(id.left_drawer); drawer = this.findViewById(id.drawer_layout); if (drawer instanceof DrawerLayout) { // if phone getSupportActionBar().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, (DrawerLayout) drawer, string.drawer_open_desc, string.drawer_closed_desc) { /** * Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { focusOnFragment = false; if (mActionMode != null) mActionMode.finish(); MainActivity.this.invalidateOptionsMenu(); // onPrepareOptionsMenu() } /** * Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { focusOnFragment = true; if (selectedRow != -1) selectItem(selectedRow); MainActivity.this.selectedRow = -1; MainActivity.this.invalidateOptionsMenu(); // onPrepareOptionsMenu() } }; Resources.Theme theme = getTheme(); TypedValue darkColorValue = new TypedValue(); TypedValue primaryColorValue = new TypedValue(); theme.resolveAttribute(R.attr.colorPrimaryDark, darkColorValue, true); theme.resolveAttribute(R.attr.colorPrimary, primaryColorValue, true); ((DrawerLayout) drawer).addDrawerListener(mDrawerToggle); ((DrawerLayout) drawer).setStatusBarBackground(null); if (themeNum > 0 && themeNum != 7) { // Is not Amber or Dark final ImageView drawerHeader = (ImageView) findViewById(id.drawer_header); drawerHeader.setColorFilter(darkColorValue.data, PorterDuff.Mode.OVERLAY); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(null, null, primaryColorValue.data); this.setTaskDescription(taskDescription); } } drawerListener = new DrawerItemClickListener(); drawerList.setOnItemClickListener(drawerListener); Intent intent = getIntent(); String extra = intent.getStringExtra(Intent.EXTRA_TEXT); Lyrics receivedLyrics = getBeamedLyrics(intent); if (receivedLyrics != null) { updateLyricsFragment(0, 0, false, receivedLyrics); } else { String s = intent.getAction(); if ("com.geecko.QuickLyric.getLyrics".equals(s) && intent.getStringArrayExtra("TAGS") != null) { String[] metadata = intent.getStringArrayExtra("TAGS"); String artist = metadata[0]; String track = metadata[1]; updateLyricsFragment(0, artist, track); } else if ("android.intent.action.SEND".equals(s)) { new IdDecoder(this, init(fragmentManager, true)).execute(getIdUrl(extra)); } else init(fragmentManager, false); } boolean seenIntro = getSharedPreferences("intro_slides", Context.MODE_PRIVATE).getBoolean("seen", false); if (!seenIntro) { registerTempReceiver(); setupDemoScreen(); } SharedPreferences updatePrefs = getSharedPreferences("update_tracker", Context.MODE_PRIVATE); int versionCode = updatePrefs.getInt("VERSION_CODE", seenIntro ? BuildConfig.VERSION_CODE - 1 : BuildConfig.VERSION_CODE); updatePrefs.edit().putInt("VERSION_CODE", BuildConfig.VERSION_CODE).apply(); if (versionCode < BuildConfig.VERSION_CODE) onAppUpdated(versionCode); }
From source file:com.evandroid.musica.MainLyricActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String action = intent.getAction(); String extra = intent.getStringExtra(Intent.EXTRA_TEXT); if (action != null) { switch (action) { case NfcAdapter.ACTION_NDEF_DISCOVERED: Lyrics receivedLyrics = getBeamedLyrics(intent); if (receivedLyrics != null) updateLyricsFragment(0, 0, false, receivedLyrics); break; case "android.intent.action.SEND": LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) getFragmentManager() .findFragmentByTag(LYRICS_FRAGMENT_TAG); new IdDecoder(this, lyricsViewFragment).execute(getIdUrl(extra)); break; case "com.evandroid.music.getLyrics": String[] metadata = intent.getStringArrayExtra("TAGS"); if (metadata != null) { String artist = metadata[0]; String track = metadata[1]; LyricsViewFragment lyricsFragment = (LyricsViewFragment) getFragmentManager() .findFragmentByTag(LYRICS_FRAGMENT_TAG); lyricsFragment.fetchLyrics(artist, track); }/*from ww w . j a v a 2 s . co m*/ break; case "com.evandroid.music.updateDBList": updateDBList(); break; } } }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PHOTO://ww w .j av a 2 s .c om if (resultCode == RESULT_OK) { getPhoto(data.getData()); } break; case TAGS: if ((resultCode == RESULT_OK) && data.hasExtra(Stags) && data.hasExtra(Accounts.SID)) mAccountsTags.put(data.getLongExtra(Accounts.SID, Sonet.INVALID_ACCOUNT_ID), data.getStringArrayExtra(Stags)); break; } }
From source file:com.shafiq.myfeedle.core.MyfeedleCreatePost.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PHOTO://from ww w. j a v a 2 s. c o m if (resultCode == RESULT_OK) { getPhoto(data.getData()); } break; case TAGS: if ((resultCode == RESULT_OK) && data.hasExtra(Stags) && data.hasExtra(Accounts.SID)) mAccountsTags.put(data.getLongExtra(Accounts.SID, Myfeedle.INVALID_ACCOUNT_ID), data.getStringArrayExtra(Stags)); break; } }
From source file:org.schabi.newpipe.report.ErrorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ThemeHelper.setTheme(this, true); setContentView(R.layout.activity_error); Intent intent = getIntent(); try {//from www .j a v a 2 s. c o m ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.error_report_title); actionBar.setDisplayShowTitleEnabled(true); } catch (Throwable e) { Log.e(TAG, "Error turing exception handling"); e.printStackTrace(); } reportButton = (Button) findViewById(R.id.errorReportButton); userCommentBox = (EditText) findViewById(R.id.errorCommentBox); errorView = (TextView) findViewById(R.id.errorView); infoView = (TextView) findViewById(R.id.errorInfosView); errorMessageView = (TextView) findViewById(R.id.errorMessageView); ActivityCommunicator ac = ActivityCommunicator.getCommunicator(); returnActivity = ac.returnActivity; errorInfo = intent.getParcelableExtra(ERROR_INFO); errorList = intent.getStringArrayExtra(ERROR_LIST); //importand add gurumeditaion addGuruMeditaion(); currentTimeStamp = getCurrentTimeStamp(); reportButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:" + ERROR_EMAIL_ADDRESS)) .putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT) .putExtra(Intent.EXTRA_TEXT, buildJson()); startActivity(Intent.createChooser(intent, "Send Email")); } }); reportButton.setEnabled(false); globIpRangeThread = new Thread(new IpRagneRequester()); globIpRangeThread.start(); // normal bugreport buildInfo(errorInfo); if (errorInfo.message != 0) { errorMessageView.setText(errorInfo.message); } else { errorMessageView.setVisibility(View.GONE); findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE); } errorView.setText(formErrorText(errorList)); //print stack trace once again for debugging: for (String e : errorList) { Log.e(TAG, e); } }
From source file:com.synox.android.ui.activity.FileDisplayActivity.java
private void requestMultipleUpload(Intent data, int resultCode) { String[] filePaths = data.getStringArrayExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES); if (filePaths != null) { String[] remotePaths = new String[filePaths.length]; String remotePathBase = null; if (getCurrentDir() != null && getCurrentDir().getRemotePath() != null) { remotePathBase = getCurrentDir().getRemotePath(); }//from w w w.j a va 2s. com for (int j = 0; j < remotePaths.length; j++) { remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName(); } Intent i = new Intent(this, FileUploader.class); i.putExtra(FileUploader.KEY_ACCOUNT, getAccount()); i.putExtra(FileUploader.KEY_LOCAL_FILE, filePaths); i.putExtra(FileUploader.KEY_REMOTE_FILE, remotePaths); i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_MULTIPLE_FILES); if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE); startService(i); } else { Log_OC.d(TAG, "User clicked on 'Update' with no selection"); Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected), Toast.LENGTH_LONG); t.show(); } }
From source file:com.freeme.filemanager.view.FileViewFragment.java
public void init() { long time1 = System.currentTimeMillis(); //Debug.startMethodTracing("file_view"); ViewStub stub = (ViewStub) mRootView.findViewById(R.id.viewContaniner); stub.setLayoutResource(R.layout.file_explorer_list); stub.inflate();/*w w w.ja va 2 s . c om*/ ActivitiesManager.getInstance().registerActivity(ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity); mFileCagetoryHelper = new FileCategoryHelper(mActivity); mFileViewInteractionHub = new FileViewInteractionHub(this, 1); // */ modify by droi liuhaoran for stop run /*/ Added by tyd wulianghuan 2013-12-12 mCleanUpDatabaseHelper = new CleanUpDatabaseHelper(mActivity); mDatabase = mCleanUpDatabaseHelper.openDatabase(); mFolderNameMap = new HashMap<String, String>(); //*/ // */add by droi liuhaoran for get Sd listener on 20160419 mApplication = (FileManagerApplication) mActivity.getApplication(); // */ // notifyFileChanged(); Intent intent = mActivity.getIntent(); String action = intent.getAction(); if (!TextUtils.isEmpty(action) && (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT))) { mFileViewInteractionHub.setMode(Mode.Pick); boolean pickFolder = intent.getBooleanExtra(PICK_FOLDER, false); if (!pickFolder) { String[] exts = intent.getStringArrayExtra(EXT_FILTER_KEY); if (exts != null) { mFileCagetoryHelper.setCustomCategory(exts); } } else { mFileCagetoryHelper.setCustomCategory(new String[] {} /* * folder * only */); mRootView.findViewById(R.id.pick_operation_bar).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.button_pick_confirm).setOnClickListener(new OnClickListener() { public void onClick(View v) { try { Intent intent = Intent.parseUri(mFileViewInteractionHub.getCurrentPath(), 0); mActivity.setResult(Activity.RESULT_OK, intent); mActivity.finish(); } catch (URISyntaxException e) { e.printStackTrace(); } } }); mRootView.findViewById(R.id.button_pick_cancel).setOnClickListener(new OnClickListener() { public void onClick(View v) { mActivity.finish(); } }); } } else { mFileViewInteractionHub.setMode(Mode.View); } mVolumeSwitch = (ImageButton) mRootView.findViewById(R.id.volume_navigator); updateVolumeSwitchState(); mGalleryNavigationBar = (RelativeLayout) mRootView.findViewById(R.id.gallery_navigation_bar); mVolumeSwitch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { int visibility = getVolumesListVisibility(); if (visibility == View.GONE) { buildVolumesList(); showVolumesList(true); } else if (visibility == View.VISIBLE) { showVolumesList(false); } } }); mFileListView = (ListView) mRootView.findViewById(R.id.file_path_list); mFileIconHelper = new FileIconHelper(mActivity); mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, mFileNameList, mFileViewInteractionHub, mFileIconHelper); boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD, !FileExplorerPreferenceActivity.isReadRoot(mActivity)); Log.i(LOG_TAG, "baseSd = " + baseSd); String rootDir = intent.getStringExtra(ROOT_DIRECTORY); if (!TextUtils.isEmpty(rootDir)) { if (baseSd && this.sdDir.startsWith(rootDir)) { rootDir = this.sdDir; } } else { rootDir = baseSd ? this.sdDir : GlobalConsts.ROOT_PATH; } String currentDir = FileExplorerPreferenceActivity.getPrimaryFolder(mActivity); Uri uri = intent.getData(); if (uri != null) { if (baseSd && this.sdDir.startsWith(uri.getPath())) { currentDir = this.sdDir; } else { currentDir = uri.getPath(); } } initVolumeState(); mBackspaceExit = (uri != null) && (TextUtils.isEmpty(action) || (!action.equals(Intent.ACTION_PICK) && !action.equals(Intent.ACTION_GET_CONTENT))); mFileListView.setAdapter(mAdapter); IntentFilter intentFilter = new IntentFilter(); // add by xueweili for get sdcard intentFilter.setPriority(1000); /* * intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); * intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); * intentFilter.addAction(Intent.ACTION_MEDIA_EJECT); */ if (!mReceiverTag) { mReceiverTag = true; intentFilter.addAction(GlobalConsts.BROADCAST_REFRESH); intentFilter.addDataScheme("file"); mActivity.registerReceiver(mReceiver, intentFilter); } // */add by droi liuhaoran for get Sd listener on 20160419 mApplication.addSDCardChangeListener(this); // */ setHasOptionsMenu(true); // add by mingjun for load file mRootView.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8) { isLayout = arg1; } }); loadDialog = new ProgressDialog(mRootView.getContext()); }