List of usage examples for android.content Intent getFlags
public @Flags int getFlags()
From source file:org.readium.sdk.android.launcher.WebViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_view); mWebview = (WebView) findViewById(R.id.webview); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) { WebView.setWebContentsDebuggingEnabled(true); }//from w ww.j av a 2 s. c om mPageInfo = (TextView) findViewById(R.id.page_info); initWebView(); Intent intent = getIntent(); if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) { Bundle extras = intent.getExtras(); if (extras != null) { mContainer = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID)); if (mContainer == null) { finish(); return; } mPackage = mContainer.getDefaultPackage(); String rootUrl = "http://" + EpubServer.HTTP_HOST + ":" + EpubServer.HTTP_PORT + "/"; mPackage.setRootUrls(rootUrl, null); try { mOpenPageRequestData = OpenPageRequest .fromJSON(extras.getString(Constants.OPEN_PAGE_REQUEST_DATA)); } catch (JSONException e) { Log.e(TAG, "Constants.OPEN_PAGE_REQUEST_DATA must be a valid JSON object: " + e.getMessage(), e); } } } // No need, EpubServer already launchers its own thread // new AsyncTask<Void, Void, Void>() { // @Override // protected Void doInBackground(Void... params) { // //xxx // return null; // } // }.execute(); mServer = new EpubServer(EpubServer.HTTP_HOST, EpubServer.HTTP_PORT, mPackage, quiet, dataPreProcessor); mServer.startServer(); // Load the page skeleton mWebview.loadUrl(READER_SKELETON); mViewerSettings = new ViewerSettings(ViewerSettings.SyntheticSpreadMode.AUTO, ViewerSettings.ScrollMode.AUTO, 100, 20); mReadiumJSApi = new ReadiumJSApi(new ReadiumJSApi.JSLoader() { @Override public void loadJS(String javascript) { mWebview.loadUrl(javascript); } }); }
From source file:com.android.tv.settings.accessories.AddAccessoryActivity.java
@Override public void onNewIntent(Intent intent) { if (ACTION_CONNECT_INPUT.equals(intent.getAction()) && (intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) == 0) { // We were the front most app and we got a new intent. // If screen saver is going, stop it. try {//from w ww.j av a 2s. c o m if (mDreamManager != null && mDreamManager.isDreaming()) { mDreamManager.awaken(); } } catch (RemoteException e) { // Do nothing. } KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_PAIRING) { if (event.getAction() == KeyEvent.ACTION_UP) { onHwKeyEvent(false); } else if (event.getAction() == KeyEvent.ACTION_DOWN) { onHwKeyEvent(true); } } } else { setIntent(intent); } }
From source file:org.mklab.mikity.android.MainActivity.java
/** * This is called after the file manager finished. {@inheritDoc} *//* w w w.ja v a 2 s . c om*/ @Override protected void onActivityResult(int requestCode, int resultCode, Intent resultData) { super.onActivityResult(requestCode, resultCode, resultData); switch (requestCode) { case REQUEST_CODE_LOAD_MODEL_DATA_FILE: if (resultCode == RESULT_OK && resultData != null) { final Uri uri = resultData.getData(); final int takeFlags = resultData.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); getContentResolver().takePersistableUriPermission(uri, takeFlags); loadModelData(uri); } break; case REQUEST_CODE_LOAD_SOURCE_DATA_FILE: if (resultCode == RESULT_OK && resultData != null) { final Uri uri = resultData.getData(); loadSourceData(uri, this.sourceIdForIntent); } break; case REQUEST_CODE_SAVE_MODEL_DATA_FILE: if (resultCode == RESULT_OK && resultData != null) { final Uri uri = resultData.getData(); saveAsModelData(uri); } break; default: break; } }
From source file:com.tasomaniac.openwith.resolver.ResolverActivity.java
private Intent makeMyIntent() { Intent intent = new Intent(getIntent()); intent.setComponent(null);//from w w w . j a v a 2s . c o m // The resolver activity is set to be hidden from recent tasks. // we don't want this attribute to be propagated to the next activity // being launched. Note that if the original Intent also had this // flag set, we are now losing it. That should be a very rare case // and we can live with this. intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); return intent; }
From source file:freed.ActivityAbstract.java
@TargetApi(VERSION_CODES.KITKAT) @Override/*from w w w . j av a2 s .co m*/ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) { // The document selected by the user won't be returned in the intent. // Instead, a URI to that document will be contained in the return intent // provided to this method as a parameter. // Pull that URI using resultData.getData(). Uri uri = null; if (data != null) { uri = data.getData(); int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Check for the freshest data. getContentResolver().takePersistableUriPermission(uri, takeFlags); appSettingsManager.SetBaseFolder(uri.toString()); if (resultCallback != null) { resultCallback.onActivityResultCallback(uri); resultCallback = null; } } } }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.SafeProfileFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent resultData) { if (peer.getSK() == null) { return;//w w w . ja v a2 s . com } if (resultCode == Activity.RESULT_OK && resultData != null) { Uri uri = null; if (requestCode == SELECT_PROFILE_PHOTO) { uri = resultData.getData(); Log.i("Uri", "Uri: " + uri.toString()); } else if (requestCode == SELECT_PPROFILE_PHOTO_KITKAT) { uri = resultData.getData(); Log.i("Uri_kitkat", "Uri: " + uri.toString()); final int takeFlags = resultData.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Check for the freshest data. getActivity().getContentResolver().takePersistableUriPermission(uri, takeFlags); } selectedImagePath = FileUtils.getPath(getActivity(), uri); Log.i("path", "path: " + selectedImagePath); selectImageFile = new File(selectedImagePath); /* Bitmap bmp = BitmapFactory.decodeFile(selectedImagePath);*/ // String strFromBmp = PhotoUtil.BitmapToString(bmp); Bitmap bmp = PhotoUtil.decodeSampledBitmapFromFile(selectedImagePath, 80, 80); //TODO fix the loading image byte[] icon; icon = PhotoUtil.BitmapToByteArray(bmp, 100); /* int quality = 100;*/ Log.i(TAG, "SafeProfile: Icon length=" + icon.length); /*DD.MAX_PEER_ICON_LENGTH = 30000; while (icon.length > DD.MAX_PEER_ICON_LENGTH && quality > 0) { quality -= 5; icon = PhotoUtil.BitmapToByteArray(bmp, quality); Log.i(TAG, "SafeProfile: Icon length=" + icon.length + " quality=" + quality); } Log.i(TAG, "SafeProfile: Icon length=" + icon.length + " quality=" + quality);// Util.stringSignatureFromByte(icon)); */ if (peer != null) { peer = D_Peer.getPeerByPeer_Keep(peer); } if (peer != null) { if (peer.getSK() != null) { if (peer.setIcon(icon)) { peer.sign(); peer.storeRequest(); } peer.releaseReference(); } } imgbut.setImageBitmap(bmp); } }
From source file:org.andstatus.app.msg.ConversationActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (ActivityRequestCode.fromId(requestCode)) { case SELECT_ACCOUNT_TO_ACT_AS: if (resultCode == RESULT_OK) { MyAccount myAccount = MyContextHolder.get().persistentAccounts() .fromAccountName(data.getStringExtra(IntentExtra.ACCOUNT_NAME.key)); if (myAccount.isValid()) { mContextMenu.setMyActor(myAccount); mContextMenu.showContextMenu(); }//from www . jav a 2 s .c o m } break; case ATTACH: if (resultCode == RESULT_OK && data != null) { Uri uri = UriUtils.notNull(data.getData()); if (!UriUtils.isEmpty(uri)) { UriUtils.takePersistableUriPermission(getActivity(), uri, data.getFlags()); mMessageEditor.startEditingCurrentWithAttachedMedia(uri); } } break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.OrgProfile.java
@SuppressLint("NewApi") @Override//from w ww . jav a2 s. co m protected void onActivityResult(int requestCode, int resultCode, Intent resultData) { if (resultCode == RESULT_OK && resultData != null) { Uri uri = null; if (requestCode == SELECT_PROFILE_PHOTO) { uri = resultData.getData(); Log.i("Uri", "Uri: " + uri.toString()); } else if (requestCode == SELECT_PPROFILE_PHOTO_KITKAT) { uri = resultData.getData(); Log.i("Uri_kitkat", "Uri: " + uri.toString()); final int takeFlags = resultData.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Check for the freshest data. getContentResolver().takePersistableUriPermission(uri, takeFlags); } selectedImagePath = FileUtils.getPath(this, uri); Log.i("path", "path: " + selectedImagePath); Bitmap bmp = BitmapFactory.decodeFile(selectedImagePath); // String strFromBmp = PhotoUtil.BitmapToString(bmp); byte[] icon = PhotoUtil.BitmapToByteArray(bmp, 100); Log.i(TAG, Util.stringSignatureFromByte(icon)); byteIcon = icon; Log.d(TAG, "selected constituent pic: " + byteIcon.length); setProfilePhoto.setImageBitmap(bmp); } }
From source file:com.mikecorrigan.bohrium.pubsub.RegistrationClient.java
@SafeVarargs private final void handleAuthToken(AccountManagerFuture<Bundle>... tokens) { Log.v(TAG, "handleAuthToken"); try {/*from w w w . ja v a2 s.c om*/ Bundle result = tokens[0].getResult(); Intent intent = (Intent) result.get(AccountManager.KEY_INTENT); if (intent != null) { Log.i(TAG, "Launch activity before getting authToken: intent=" + intent); setStateAndNotify(REGISTRATION_STATE_REGISTERING, REGISTRATION_SUBSTATE_PROMPTING_USER); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); notifyLaunchIntent(intent); return; } String authToken = result.getString(AccountManager.KEY_AUTHTOKEN); if (mNeedInvalidate) { mNeedInvalidate = false; Log.i(TAG, "Invalidating token and starting over."); // Invalidate auth token. AccountManager mgr = AccountManager.get(this); mgr.invalidateAuthToken(mConfiguration.getString(ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE), authToken); setStateAndNotify(REGISTRATION_STATE_REGISTERING, REGISTRATION_SUBSTATE_INVALIDATED_AUTH_TOKEN); // Initiate the request again. requestAuthToken(); return; } else { Log.i(TAG, "Received authToken=" + authToken); mConfiguration.putString(AUTH_TOKEN, authToken); setStateAndNotify(REGISTRATION_STATE_REGISTERING, REGISTRATION_SUBSTATE_HAVE_AUTH_TOKEN); // Move on to the next step, request auth cookie. requestAuthCookie(); return; } } catch (Exception e) { Log.e(TAG, "Exception " + e); Log.e(TAG, Log.getStackTraceString(e)); } setStateAndNotify(REGISTRATION_STATE_ERROR, REGISTRATION_SUBSTATE_ERROR_AUTH_TOKEN); }
From source file:org.geometerplus.android.fbreader.FBReader.java
@Override protected void onNewIntent(final Intent intent) { final String action = intent.getAction(); final Uri data = intent.getData(); if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { super.onNewIntent(intent); } else if (Intent.ACTION_VIEW.equals(action) && data != null && "fbreader-action".equals(data.getScheme())) { myFBReaderApp.runAction(data.getEncodedSchemeSpecificPart(), data.getFragment()); } else if (Intent.ACTION_VIEW.equals(action) || FBReaderIntents.Action.VIEW.equals(action)) { myOpenBookIntent = intent;//from w w w . jav a 2s.c o m if (myFBReaderApp.Model == null && myFBReaderApp.ExternalBook != null) { final ExternalFormatPlugin plugin = (ExternalFormatPlugin) myFBReaderApp.ExternalBook .getPluginOrNull(); try { startActivity(PluginUtil.createIntent(plugin, PluginUtil.ACTION_KILL)); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } } else if (FBReaderIntents.Action.PLUGIN.equals(action)) { new RunPluginAction(this, myFBReaderApp, data).run(); } else if (Intent.ACTION_SEARCH.equals(action)) { final String pattern = intent.getStringExtra(SearchManager.QUERY); final Runnable runnable = new Runnable() { public void run() { final TextSearchPopup popup = (TextSearchPopup) myFBReaderApp.getPopupById(TextSearchPopup.ID); popup.initPosition(); myFBReaderApp.MiscOptions.TextSearchPattern.setValue(pattern); if (myFBReaderApp.getTextView().search(pattern, true, false, false, false) != 0) { runOnUiThread(new Runnable() { public void run() { myFBReaderApp.showPopup(popup.getId()); } }); } else { runOnUiThread(new Runnable() { public void run() { UIUtil.showErrorMessage(FBReader.this, "textNotFound"); popup.StartPosition = null; } }); } } }; UIUtil.wait("search", runnable, this); } else if (FBReaderIntents.Action.CLOSE.equals(intent.getAction())) { myCancelIntent = intent; myOpenBookIntent = null; } else if (FBReaderIntents.Action.PLUGIN_CRASH.equals(intent.getAction())) { final Book book = FBReaderIntents.getBookExtra(intent); myFBReaderApp.ExternalBook = null; myOpenBookIntent = null; getCollection().bindToService(this, new Runnable() { public void run() { Book b = myFBReaderApp.Collection.getRecentBook(0); if (b.equals(book)) { b = myFBReaderApp.Collection.getRecentBook(1); } myFBReaderApp.openBook(b, null, null, FBReader.this); } }); } else { super.onNewIntent(intent); } }