List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:com.honglang.zxing.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). This is // necessary because we don't // want to open the camera driver and measure the screen size if we're // going to show the help on // first launch. That led to bugs where the scanning rectangle was the // wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); // resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null;/*from w ww .j a v a 2 s . com*/ lastResult = null; resetStatusView(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); } beepManager.updatePrefs(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); decodeHints = DecodeHintManager.parseDecodeHints(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) { // Scan only products and send the result to mobile Product // Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(dataString); // scanFromWebPageManager = new // ScanFromWebPageManager(inputUri); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); // Allow a sub-set of the hints to be specified by the caller. decodeHints = DecodeHintManager.parseDecodeHints(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); prefs = getSharedPreferences("com.roamprocess1.roaming4world", Context.MODE_PRIVATE); stored_chatuserNumber = "com.roamprocess1.roaming4world.stored_chatuserNumber"; stored_user_mobile_no = "com.roamprocess1.roaming4world.user_mobile_no"; stored_user_country_code = "com.roamprocess1.roaming4world.user_country_code"; stored_supportnumber = "com.roamprocess1.roaming4world.support_no"; stored_server_ipaddress = "com.roamprocess1.roaming4world.server_ip"; usernum = prefs.getString(stored_user_country_code, "") + prefs.getString(stored_user_mobile_no, ""); System.out.println("MessageActivity.java before if statement of savedInstanceState "); if (savedInstanceState == null) { // During initial setup, plug in the details fragment. System.out.println("MessageActivity.java after if statement of savedInstanceState "); detailFragment = new MessageFragment(); detailFragment.setArguments(getIntent().getExtras()); getSupportFragmentManager().beginTransaction().add(android.R.id.content, detailFragment).commit(); detailFragment.setOnQuitListener(this); }//from w w w . j a v a 2 s .c o m if (getConnectivityStatus(getApplicationContext()) == TYPE_NOT_CONNECTED) dialogBoxNoInternet(); broadcastReceiver_socket_userStatus = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String action = intent.getAction(); Log.d("Receiver", "Broadcast received: " + action); if (action.equals(ChatSocket.USER_STATUS)) { String state = intent.getExtras().getString(ChatSocket.USER_STATUS); Log.d("Receiver state", state + " @"); setStatus(state); } } }; broadcastReceiver_lost = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Log.d("broadcastReceiver_lost", "called"); tv_userStatus.setText(""); } }; registerReceiver(broadcastReceiver_lost, new IntentFilter("INTERNET_LOST")); registerReceiver(broadcastReceiver_socket_userStatus, new IntentFilter(ChatSocket.USER_STATUS)); }
From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java
private void handleIntent(Intent intent) { // ? ? //from ww w . jav a 2 s. c o m if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); // ? // doMixSearch(query); // } else if (intent.getExtras() != null) { FCMMessagingService.clear(intent.getStringExtra("traceID")); Intent traceIntent = new Intent(this, TraceActivity.class); traceIntent.putExtras(intent.getExtras()); topLayoutOnMixView.mainArView.setVisibility(View.GONE); startActivityForResult(traceIntent, SHOW_TRACE); } }
From source file:com.hichinaschool.flashcards.anki.CardEditor.java
private void fetchIntentInformation(Intent intent) { Bundle extras = intent.getExtras();//from www . ja v a 2 s . co m if (ACTION_CREATE_FLASHCARD.equals(intent.getAction())) { // mSourceLanguage = extras.getString(SOURCE_LANGUAGE); // mTargetLanguage = extras.getString(TARGET_LANGUAGE); mSourceText = new String[2]; mSourceText[0] = extras.getString(SOURCE_TEXT); mSourceText[1] = extras.getString(TARGET_TEXT); } else { String first; String second; if (extras.getString(Intent.EXTRA_SUBJECT) != null) { first = extras.getString(Intent.EXTRA_SUBJECT); } else { first = ""; } if (extras.getString(Intent.EXTRA_TEXT) != null) { second = extras.getString(Intent.EXTRA_TEXT); } else { second = ""; } Pair<String, String> messages = new Pair<String, String>(first, second); /* Filter garbage information */ Pair<String, String> cleanMessages = new FilterFacade(getBaseContext()).filter(messages); mSourceText = new String[2]; mSourceText[0] = cleanMessages.first; mSourceText[1] = cleanMessages.second; } }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@SuppressWarnings("unchecked") @Override/*from ww w . j a v a 2 s .c o m*/ public void onCreate(Bundle savedState) { super.onCreate(savedState); initViews(); if (formLocation) queryLocation(true); if (savedState != null) { if (savedState.containsKey("tempfile")) tempFile = new File(savedState.getString("tempfile")); if (savedState.containsKey("target")) resolveTarget(savedState.getString("target")); if (savedState.containsKey("tempfiles")) tempFiles = savedState.getStringArrayList("tempfiles"); if (savedState.containsKey("contents")) { contents = new ArrayList<Uri>(); String[] carr = savedState.getStringArray("contents"); for (String s : carr) contents.add(Uri.parse(s)); } } postfix = "from <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; Button uploadVisit = (Button) findViewById(R.id.upload_visit); if (passThrough || target == null) uploadVisit.setEnabled(false); else uploadVisit.setEnabled(true); /* populate data by getting STREAM parameter */ Intent i = getIntent(); Bundle b = i.getExtras(); String action = i.getAction(); if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE)) { called = true; if (i.hasExtra(Intent.EXTRA_STREAM)) { Object o = b.get(Intent.EXTRA_STREAM); /* quick and dirty. any better idea? */ try { contents.add((Uri) o); } catch (Exception e1) { try { contents = (ArrayList<Uri>) ((ArrayList<Uri>) o).clone(); } catch (Exception e2) { } } boolean exceeded = false; if (contents.size() > 5) { exceeded = true; do { contents.remove(5); } while (contents.size() > 5); } galleryChanged = true; updateImageButtons(); resetThumbnails(); updateGallery(); if (exceeded) Toast.makeText(this, " 5 . 5 ??? ? ?.", Toast.LENGTH_LONG).show(); } if (i.hasExtra(Intent.EXTRA_TEXT)) { ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TEXT)); } } else if (action.equals("share")) { called = true; /* HTC web browser uses non-standard intent */ ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TITLE)); } else if (action.equals(Intent.ACTION_VIEW)) { Uri uri = i.getData(); if (i.getCategories().contains(Intent.CATEGORY_BROWSABLE)) { passThrough = true; Pattern p = Pattern.compile("id=([\\-a-zA-Z0-9_]+)"); Matcher m = p.matcher(uri.toString()); if (m.find()) { resolveTarget(m.group(1)); } else { passThrough = false; } if (uri.getHost().equals(Application.HOST_DCMYS)) { destination = Application.DESTINATION_DCMYS; postfix = "from dc.m.dcmys.kr w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_MOOLZO)) { destination = Application.DESTINATION_MOOLZO; postfix = "- From m.oolzo.com w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_DCINSIDE)) { destination = Application.DESTINATION_DCINSIDE; } setDefaultImage(); } } reloadConfigurations(); }
From source file:br.liveo.ndrawer.ui.activity.MainActivity.java
License:asdf
public void registBroadcastReceiver() { Log.i("?", "?"); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override//from w ww .ja v a2s . c o m public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(QuickstartPreferences.REGISTRATION_READY)) { } else if (action.equals(QuickstartPreferences.REGISTRATION_GENERATING)) { } else if (action.equals(QuickstartPreferences.REGISTRATION_COMPLETE)) { String token = intent.getStringExtra("token"); Log.i("token", token); prefs = getSharedPreferences("PrefName", MODE_PRIVATE); SharedPreferences.Editor edit = prefs.edit(); edit.putString("token", token); edit.commit(); String useremail = prefs.getString("useremail", ""); try { String url = "http://125.131.73.198:3000/token"; RequestClass rc = new RequestClass(url); rc.AddParam("useremail", useremail); rc.AddParam("token", token); rc.Execute(1); String response = rc.getResponse(); if (response.length() == 0) { } else { } } catch (Exception e) { e.printStackTrace(); } } } }; }
From source file:edu.mit.media.funf.probe.Probe.java
/** * Send some values to each requesting pending intent * @param valuesIntent//from w w w. jav a2 s. c om */ protected void _callback_registered(Intent valuesIntent, PendingIntent callback) { long epochTimestamp = valuesIntent.getLongExtra(TIMESTAMP, 0L); Set<PendingIntent> callbacks = new HashSet<PendingIntent>(); if (callback != null) { callbacks.add(callback); } ArrayList<Intent> requests = null; if (requestsIntent != null) { requests = requestsIntent.getParcelableArrayListExtra(INTERNAL_REQUESTS_KEY); } if (ACTION_DATA.equals(valuesIntent.getAction())) { // Send to all requesters if (requests != null && !requests.isEmpty()) { JSONObject dataSentTimes = null; try { dataSentTimes = new JSONObject( getHistoryPrefs().getString(MOST_RECENT_DATA_BY_REQUEST_KEY, "{}")); } catch (JSONException e) { Log.e(TAG, "Unable to parse data sent history."); dataSentTimes = new JSONObject(); } Parameter[] availableParameters = getAvailableParameters(); for (Intent request : requests) { PendingIntent requesterCallback = request.getParcelableExtra(CALLBACK_KEY); ArrayList<Bundle> dataRequests = Utils.getArrayList(request.getExtras(), REQUESTS_KEY); for (Bundle dataRequest : dataRequests) { String requestKey = normalizedStringRepresentation(dataRequest, getAvailableParameters()); long lastDataSentTime = dataSentTimes.optLong(requestKey); // TODO: If data request accepts passive data, but also needs data enforced on a schedule // we may need to make logic more complicated if (isDataRequestSatisfied(dataRequest, availableParameters, epochTimestamp, lastDataSentTime) || isDataRequestAcceptingPassiveData(dataRequest, availableParameters)) { callbacks.add(requesterCallback); try { dataSentTimes.put(requestKey, epochTimestamp); } catch (JSONException e) { Log.e(TAG, "Unable to store data sent time in ."); } } } } // Save the data sent times getHistoryPrefs().edit().putString(MOST_RECENT_DATA_BY_REQUEST_KEY, dataSentTimes.toString()) .putLong(MOST_RECENT_DATA_KEY, epochTimestamp).commit(); } } else { // Add all for (Intent request : requests) { PendingIntent requesterCallback = request.getParcelableExtra(CALLBACK_KEY); callbacks.add(requesterCallback); } } Log.d(TAG, "Sent probe data at " + epochTimestamp); for (PendingIntent requesterCallback : callbacks) { try { requesterCallback.send(this, 0, valuesIntent); } catch (CanceledException e) { Log.w(TAG, "Unable to send to canceled pending intent at " + epochTimestamp); Map<PendingIntent, Intent> callbacksToRequests = getCallbacksToRequests(requests); Intent request = callbacksToRequests.get(requesterCallback); if (request != null) { deadRequests.add(request); } } } updateRequests(); }
From source file:com.digitalbuana.smiles.ui.ContactAdd.java
@Override protected void onInflate(Bundle savedInstanceState) { setContentView(R.layout.contact_add); ListView listView = getListView(); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.contact_add_header, listView, false); listView.addHeaderView(view, null, false); // accountView = (Spinner) view.findViewById(R.id.contact_account); // accountView.setAdapter(new AccountChooseAdapter(this)); // accountView.setOnItemSelectedListener(this); userView = (EditText) view.findViewById(R.id.contact_user); nameView = (EditText) view.findViewById(R.id.contact_name); ((Button) view.findViewById(R.id.ok)).setOnClickListener(this); String name;/*from ww w. j av a 2s . co m*/ Intent intent = getIntent(); if (savedInstanceState != null) { account = savedInstanceState.getString(SAVED_ACCOUNT); user = savedInstanceState.getString(SAVED_USER); name = savedInstanceState.getString(SAVED_NAME); } else { account = getAccount(intent); user = getUser(intent); if (account == null || user == null) name = null; else { name = RosterManager.getInstance().getName(account, user); if (user.equals(name)) name = null; } } if (account == null) { Collection<String> accounts = AccountManager.getInstance().getAccounts(); if (accounts.size() == 1) account = accounts.iterator().next(); } // if (account != null) { // for (int position = 0; position < accountView.getCount(); position++) // if (account.equals(accountView.getItemAtPosition(position))) { // accountView.setSelection(position); // break; // } // } if (user != null) userView.setText(StringUtils.replaceStringEquals(user)); if (name != null) nameView.setText(name); if (ACTION_SUBSCRIPTION_REQUEST.equals(intent.getAction())) { subscriptionRequest = PresenceManager.getInstance().getSubscriptionRequest(account, user); if (subscriptionRequest == null) { Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); finish(); return; } } else { subscriptionRequest = null; } }
From source file:org.deviceconnect.android.deviceplugin.host.HostDeviceService.java
@Override public IBinder onBind(final Intent intent) { if ("camera".equals(intent.getAction())) { return mCameraService; } else {/*from w w w. ja va2 s . c om*/ return mStub; } }