List of usage examples for android.content Intent getType
public @Nullable String getType()
From source file:com.nekomeshi312.whiteboardcorrection.WhiteBoardCorrectionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_Sherlock);/*from w w w.j a v a 2 s.com*/ super.onCreate(savedInstanceState); //action bar ???s??status bar? final android.view.Window wnd = getWindow(); wnd.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); wnd.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.activity_white_board_correction); mCameraSetting = CameraAndParameters.newInstance(this); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowHomeEnabled(true); //actionbar????) actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_background)); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); FragmentManager fm = getSupportFragmentManager(); mFragCameraView = (CameraViewFragment) fm.findFragmentByTag(FRAG_CAMERA_VIEW_TAG); mBoardCheckFragment = (WhiteBoardCheckFragment) fm.findFragmentByTag(FRAG_WB_CHECK_TAG); mBoardResultFragment = (WhiteBoardResultFragment) fm.findFragmentByTag(FRAG_WB_RESULT_TAG); Intent intent = (Intent) getIntent(); if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getType() != null) { if (!intent.getType().equals("image/jpeg") && !intent.getType().equals("image/jpg")) { Toast.makeText(this, R.string.error_msg_non_supported_image_format, Toast.LENGTH_SHORT).show(); Log.w(LOG_TAG, "Intent unsupported image format"); } else { int[] size = new int[2]; String fn = MyUtils.getImageInfoFromIntent(this, intent, size); if (fn != null) { //OpenCV?????? String[] newFn = new String[2]; if (copyImageToSD(fn, newFn) == true) { mWhiteBoardCheckInfo.mFilePath = newFn[0]; mWhiteBoardCheckInfo.mFileName = newFn[1]; mWhiteBoardCheckInfo.mPicWidth = size[0]; mWhiteBoardCheckInfo.mPicHeight = size[1]; mWhiteBoardCheckInfo.mIsCaptured = false; mWhiteBoardCheckInfo.mPrevWidth = 0; mWhiteBoardCheckInfo.mPrevHeight = 0; } } } } }
From source file:mobisocial.socialkit.musubi.Musubi.java
public DbObj objFromIntent(Intent intent) { Log.d(TAG, "fetching obj from " + intent); if (intent.hasExtra(EXTRA_OBJ_URI)) { try {/*ww w .j a v a2s . co m*/ Uri objUri = intent.getParcelableExtra(EXTRA_OBJ_URI); return objForUri(objUri); } catch (Exception e) { if (DBG) Log.e(TAG, "couldnt get obj from uri", e); } } if (intent.getType() != null && intent.getType().startsWith("vnd.musubi.obj/")) { if (intent.getData() != null) { return objForUri(intent.getData()); } } if (DBG) Log.e(TAG, "no obj found"); return null; }
From source file:de.earthlingz.oerszebra.DroidZebra.java
/** * Called when the activity is first created. *///from w w w . ja v a2 s . c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initBoard(); clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); setContentView(R.layout.spash_layout); new ActionBarHelper(this).hide(); mZebraThread = new ZebraEngine(new AndroidContext(this)); mZebraThread.setHandler(new DroidZebraHandler(getState(), this, mZebraThread)); this.settingsProvider = new GlobalSettingsLoader(this); this.settingsProvider.setOnChangeListener(this); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); Log.i("Intent", type + " " + action); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type) || "message/rfc822".equals(type)) { mZebraThread.setInitialGameState(parser.makeMoveList(intent.getStringExtra(Intent.EXTRA_TEXT))); } else { Log.e("intent", "unknown intent"); } } else if (savedInstanceState != null && savedInstanceState.containsKey("moves_played_count") && savedInstanceState.getInt("moves_played_count") > 0) { Log.i("moves_play_count", String.valueOf(savedInstanceState.getInt("moves_played_count"))); Log.i("moves_played", String.valueOf(savedInstanceState.getInt("moves_played"))); mZebraThread.setInitialGameState(savedInstanceState.getInt("moves_played_count"), savedInstanceState.getByteArray("moves_played")); } mZebraThread.start(); newCompletionPort(ZebraEngine.ES_READY2PLAY, () -> { DroidZebra.this.setContentView(R.layout.board_layout); new ActionBarHelper(DroidZebra.this).show(); DroidZebra.this.mBoardView = (BoardView) DroidZebra.this.findViewById(R.id.board); DroidZebra.this.mStatusView = (StatusView) DroidZebra.this.findViewById(R.id.status_panel); DroidZebra.this.mBoardView.setBoardState(getState()); DroidZebra.this.mBoardView.setOnMakeMoveListener(DroidZebra.this); DroidZebra.this.mBoardView.requestFocus(); DroidZebra.this.initBoard(); DroidZebra.this.loadSettings(); DroidZebra.this.mZebraThread.setEngineState(ZebraEngine.ES_PLAY); DroidZebra.this.mIsInitCompleted = true; }); }
From source file:it.imwatch.nfclottery.MainActivity.java
/** * Handles an intent as received by the Activity, be it with a MAIN or an * NDEF_DISCOVERED action./*from ww w. j a v a2 s. c o m*/ * * @param intent The intent to handle */ private void handleIntent(Intent intent) { String action = intent.getAction(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { // This is an "NFC tag scanned" intent String type = intent.getType(); Log.d(TAG, "Read tag with type: " + type); if (MIME_VCARD.equals(type) || MIME_XVCARD.equals(type)) { if (mVCardEngine == null) { mVCardEngine = new VCardEngine(); } Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); if (tag != null) { Ndef ndefTag = Ndef.get(tag); NdefMessage ndefMessage; // ndefTag can be null if the tag was INITIALIZED // but not actually written to if (ndefTag != null) { ndefMessage = ndefTag.getCachedNdefMessage(); parseAndInsertVCard(ndefMessage); } } } else { Log.i(TAG, "Ignoring NDEF with mime type: " + type); } } // Nothing else to do if this is a MAIN intent... }
From source file:org.akvo.caddisfly.ui.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MainApp mainApp = (MainApp) getApplicationContext(); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Config.FLOW_ACTION_EXTERNAL_SOURCE.equals(action) && type != null) { if ("text/plain".equals(type)) { //NON-NLS external = true;//from w w w. j a v a 2 s. c o m //mQuestionId = getIntent().getStringExtra("questionId"); String questionTitle = getIntent().getStringExtra("questionTitle"); String code = questionTitle.substring(Math.max(0, questionTitle.length() - 5)); mainApp.setSwatches(code); } } if (mStartFragment != null) { mStartFragment.refresh(); } if (getCurrentFragmentIndex() == Config.HOME_SCREEN_INDEX) { getMenuInflater().inflate(R.menu.home, menu); } updateActionBarNavigation(getCurrentFragmentIndex()); return super.onCreateOptionsMenu(menu); }
From source file:net.gsantner.opoc.util.ShareUtil.java
/** * Try to force extract a absolute filepath from an intent * * @param receivingIntent The intent from {@link Activity#getIntent()} * @return A file or null if extraction did not succeed *///from w w w .j a va 2 s. c o m public File extractFileFromIntent(Intent receivingIntent) { String action = receivingIntent.getAction(); String type = receivingIntent.getType(); File tmpf; String tmps; String fileStr; if ((Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action)) || Intent.ACTION_SEND.equals(action)) { // Markor, S.M.T FileManager if (receivingIntent.hasExtra((tmps = EXTRA_FILEPATH))) { return new File(receivingIntent.getStringExtra(tmps)); } // Analyze data/Uri Uri fileUri = receivingIntent.getData(); if (fileUri != null && (fileStr = fileUri.toString()) != null) { // Uri contains file if (fileStr.startsWith("file://")) { return new File(fileUri.getPath()); } if (fileStr.startsWith((tmps = "content://"))) { fileStr = fileStr.substring(tmps.length()); String fileProvider = fileStr.substring(0, fileStr.indexOf("/")); fileStr = fileStr.substring(fileProvider.length() + 1); // Some file managers dont add leading slash if (fileStr.startsWith("storage/")) { fileStr = "/" + fileStr; } // Some do add some custom prefix for (String prefix : new String[] { "file", "document", "root_files", "name" }) { if (fileStr.startsWith(prefix)) { fileStr = fileStr.substring(prefix.length()); } } // Next/OwnCloud Fileprovider for (String fp : new String[] { "org.nextcloud.files", "org.nextcloud.beta.files", "org.owncloud.files" }) { if (fileProvider.equals(fp) && fileStr.startsWith(tmps = "external_files/")) { return new File(Uri.decode("/storage/" + fileStr.substring(tmps.length()))); } } // AOSP File Manager/Documents if (fileProvider.equals("com.android.externalstorage.documents") && fileStr.startsWith(tmps = "/primary%3A")) { return new File(Uri.decode(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + fileStr.substring(tmps.length()))); } // Mi File Explorer if (fileProvider.equals("com.mi.android.globalFileexplorer.myprovider") && fileStr.startsWith(tmps = "external_files")) { return new File(Uri.decode(Environment.getExternalStorageDirectory().getAbsolutePath() + fileStr.substring(tmps.length()))); } // URI Encoded paths with full path after content://package/ if (fileStr.startsWith("/") || fileStr.startsWith("%2F")) { tmpf = new File(Uri.decode(fileStr)); if (tmpf.exists()) { return tmpf; } else if ((tmpf = new File(fileStr)).exists()) { return tmpf; } } } } fileUri = receivingIntent.getParcelableExtra(Intent.EXTRA_STREAM); if (fileUri != null && !TextUtils.isEmpty(tmps = fileUri.getPath()) && tmps.startsWith("/") && (tmpf = new File(tmps)).exists()) { return tmpf; } } return null; }
From source file:com.weebly.opus1269.copyeverywhere.ui.main.MainActivity.java
/** * Process intents we know about//from w w w . j a v a 2 s . c o m */ @SuppressWarnings("CallToStringEquals") private void handleIntent() { final Intent intent = getIntent(); final String action = intent.getAction(); final String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && (type != null)) { if (ClipItem.TEXT_PLAIN.equals(type)) { final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); if (sharedText != null) { final ClipItem item = new ClipItem(sharedText); ClipContentProvider.insert(this, item); showClipViewer(item); } } } else if (intent.hasExtra(ClipItem.INTENT_EXTRA_CLIP_ITEM)) { final ClipItem item = (ClipItem) intent.getSerializableExtra(ClipItem.INTENT_EXTRA_CLIP_ITEM); intent.removeExtra(ClipItem.INTENT_EXTRA_CLIP_ITEM); showClipViewer(item); } else if (intent.hasExtra(Devices.INTENT_FILTER)) { showDevices(); } }
From source file:org.akvo.caddisfly.ui.activity.MainActivity.java
@Override protected void onResume() { super.onResume(); invalidateOptionsMenu();//from www . ja va 2s . c o m mShouldFinish = false; Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); MainApp mainApp = (MainApp) getApplicationContext(); if (Config.FLOW_ACTION_EXTERNAL_SOURCE.equals(action) && type != null) { if ("text/plain".equals(type)) { //NON-NLS mQuestionTitle = getIntent().getStringExtra("questionTitle"); String code = mQuestionTitle.substring(Math.max(0, mQuestionTitle.length() - 5)); mainApp.setSwatches(code); if (mainApp.currentTestInfo == null) { String errorTitle; if (mQuestionTitle.length() > 0) { if (mQuestionTitle.length() > 30) { mQuestionTitle = mQuestionTitle.substring(0, 30); } errorTitle = mQuestionTitle; } else { errorTitle = getString(R.string.error); } AlertUtils.showAlert(this, errorTitle, R.string.testNotAvailable, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); } }, null); } else { if (external && !PreferencesUtils.getBoolean(this, R.string.showStartPageKey, true)) { onStartTest(); } } } } }
From source file:com.android.contacts.activities.ContactDetailActivity.java
/** @} */ @Override/*from ww w . j a v a2s .com*/ protected void onCreate(Bundle savedState) { super.onCreate(savedState); LogUtils.i(TAG, "[onCreate][launch]start"); ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet registerPHBReceiver(); mIsActivitFinished = false; /** M: Bug Fix for ALPS00393950 @{ */ boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this); if (!isUsingTwoPanes) { SetIndicatorUtils.getInstance().registerReceiver(this); } /** @} */ if (PhoneCapabilityTester.isUsingTwoPanes(this)) { // This activity must not be shown. We have to select the contact in the // PeopleActivity instead ==> Create a forward intent and finish final Intent originalIntent = getIntent(); Intent intent = new Intent(); intent.setAction(originalIntent.getAction()); intent.setDataAndType(originalIntent.getData(), originalIntent.getType()); // If we are launched from the outside, we should create a new task, because the user // can freely navigate the app (this is different from phones, where only the UP button // kicks the user into the full app) if (shouldUpRecreateTask(intent)) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); } else { intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); } intent.setClass(this, PeopleActivity.class); startActivity(intent); LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity.."); finish(); return; } setContentView(R.layout.contact_detail_activity); mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(), null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener); // We want the UP affordance but no app icon. // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick. ActionBar actionBar = getActionBar(); if (actionBar != null) { ///@Modify for add Customer view{ actionBar.setDisplayOptions( ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM); ///@} actionBar.setTitle(""); } Log.i(TAG, getIntent().getData().toString()); /** M: New Feature xxx @{ */ //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE if (getIntent() != null && getIntent().getData() != null) { mSimOrPhoneUri = getIntent().getData(); Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri); } else { Log.e(TAG, "Get intent data error getIntent() = " + getIntent()); } /// M: @ CT contacts detail history set listener{ ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(), ContactPluginDefault.COMMD_FOR_OP09); /// @} LogUtils.i(TAG, "[onCreate][launch]end"); }
From source file:org.akvo.caddisfly.ui.activity.MainActivity.java
void displayView(int position, boolean addToBackStack) { int index = getCurrentFragmentIndex(); if (index == position) { // requested fragment is already showing return;//from w w w .j a v a 2 s. co m } MainApp mainApp = (MainApp) getApplicationContext(); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Config.FLOW_ACTION_EXTERNAL_SOURCE.equals(action) && type != null) { if ("text/plain".equals(type)) { //NON-NLS external = true; //mQuestionId = getIntent().getStringExtra("questionId"); mQuestionTitle = getIntent().getStringExtra("questionTitle"); String code = mQuestionTitle.substring(Math.max(0, mQuestionTitle.length() - 5)); mainApp.setSwatches(code); } } if (mainApp.currentTestInfo == null) { mainApp.currentTestInfo = new TestInfo("", "", ""); } Fragment fragment; switch (position) { case Config.HOME_SCREEN_INDEX: mStartFragment = StartFragment.newInstance(external, mainApp.currentTestInfo.getCode()); fragment = mStartFragment; break; case Config.CALIBRATE_SCREEN_INDEX: mCalibrateFragment = new CalibrateFragment(); fragment = mCalibrateFragment; setupActionBarSpinner(); break; case Config.SETTINGS_SCREEN_INDEX: if (mSettingsFragment == null) { mSettingsFragment = new SettingsFragment(); } fragment = mSettingsFragment; break; default: return; } FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.container, fragment, String.valueOf(position)); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); if (addToBackStack) { ft.addToBackStack(null); } ft.commit(); invalidateOptionsMenu(); updateActionBarNavigation(position); }