List of usage examples for android.content Intent getType
public @Nullable String getType()
From source file:sharedcode.turboeditor.activity.MainActivity.java
/** * Parses the intent/*from ww w . ja v a 2s . c o m*/ */ private void parseIntent(Intent intent) { final String action = intent.getAction(); final String type = intent.getType(); if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action) || Intent.ACTION_PICK.equals(action) && type != null) { // Post event onEvent(new EventBusEvents.NewFileToOpen(new File(intent.getData().getPath()))); } else if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { onEvent(new EventBusEvents.NewFileToOpen(intent.getStringExtra(Intent.EXTRA_TEXT))); } } }
From source file:org.matrix.console.activity.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (CommonActivityUtils.shouldRestartApp()) { Log.e(LOG_TAG, "Restart the application."); CommonActivityUtils.restartApp(this); }/* www . j a v a 2 s.c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); mMyRoomList = (ExpandableListView) findViewById(R.id.listView_myRooms); // the chevron is managed in the header view mMyRoomList.setGroupIndicator(null); mAdapter = new ConsoleRoomSummaryAdapter(this, Matrix.getMXSessions(this), R.layout.adapter_item_my_rooms, R.layout.adapter_room_section_header); if (null != savedInstanceState) { if (savedInstanceState.containsKey(PUBLIC_ROOMS_LIST_LIST)) { Serializable map = savedInstanceState.getSerializable(PUBLIC_ROOMS_LIST_LIST); if (null != map) { HashMap<String, List<PublicRoom>> hash = (HashMap<String, List<PublicRoom>>) map; mPublicRoomsListList = new ArrayList<List<PublicRoom>>(hash.values()); mHomeServerNames = new ArrayList<>(hash.keySet()); } } } final Intent intent = getIntent(); if (intent.hasExtra(EXTRA_JUMP_TO_ROOM_ID)) { mAutomaticallyOpenedRoomId = intent.getStringExtra(EXTRA_JUMP_TO_ROOM_ID); } if (intent.hasExtra(EXTRA_JUMP_MATRIX_ID)) { mAutomaticallyOpenedMatrixId = intent.getStringExtra(EXTRA_JUMP_MATRIX_ID); } if (intent.hasExtra(EXTRA_ROOM_INTENT)) { mOpenedRoomIntent = intent.getParcelableExtra(EXTRA_ROOM_INTENT); } String action = intent.getAction(); String type = intent.getType(); // send files from external application if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) && type != null) { this.runOnUiThread(new Runnable() { @Override public void run() { CommonActivityUtils.sendFilesTo(HomeActivity.this, intent); } }); } mMyRoomList.setAdapter(mAdapter); Collection<MXSession> sessions = Matrix.getMXSessions(HomeActivity.this); // check if there is some valid session // the home activity could be relaunched after an application crash // so, reload the sessions before displaying the hidtory if (sessions.size() == 0) { Log.e(LOG_TAG, "Weird : onCreate : no session"); if (null != Matrix.getInstance(this).getDefaultSession()) { Log.e(LOG_TAG, "No loaded session : reload them"); startActivity(new Intent(HomeActivity.this, SplashActivity.class)); HomeActivity.this.finish(); return; } } for (MXSession session : sessions) { addSessionListener(session); } mMyRoomList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mAdapter.isRecentsGroupIndex(groupPosition)) { String roomId = null; MXSession session = null; RoomSummary roomSummary = mAdapter.getRoomSummaryAt(groupPosition, childPosition); session = Matrix.getInstance(HomeActivity.this).getSession(roomSummary.getMatrixId()); roomId = roomSummary.getRoomId(); Room room = session.getDataHandler().getRoom(roomId); // cannot join a leaving room if ((null == room) || room.isLeaving()) { roomId = null; } if (mAdapter.resetUnreadCount(groupPosition, roomId)) { session.getDataHandler().getStore().flushSummary(roomSummary); } if (null != roomId) { CommonActivityUtils.goToRoomPage(session, roomId, HomeActivity.this, null); } } else if (mAdapter.isPublicsGroupIndex(groupPosition)) { joinPublicRoom(mAdapter.getHomeServerURLAt(groupPosition), mAdapter.getPublicRoomAt(groupPosition, childPosition)); } return true; } }); mMyRoomList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { long packedPos = ((ExpandableListView) parent).getExpandableListPosition(position); final int groupPosition = ExpandableListView.getPackedPositionGroup(packedPos); if (mAdapter.isRecentsGroupIndex(groupPosition)) { final int childPosition = ExpandableListView.getPackedPositionChild(packedPos); FragmentManager fm = HomeActivity.this.getSupportFragmentManager(); IconAndTextDialogFragment fragment = (IconAndTextDialogFragment) fm .findFragmentByTag(TAG_FRAGMENT_ROOM_OPTIONS); if (fragment != null) { fragment.dismissAllowingStateLoss(); } final Integer[] lIcons = new Integer[] { R.drawable.ic_material_exit_to_app }; final Integer[] lTexts = new Integer[] { R.string.action_leave }; fragment = IconAndTextDialogFragment.newInstance(lIcons, lTexts); fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener() { @Override public void onItemClick(IconAndTextDialogFragment dialogFragment, int position) { Integer selectedVal = lTexts[position]; if (selectedVal == R.string.action_leave) { HomeActivity.this.runOnUiThread(new Runnable() { @Override public void run() { final RoomSummary roomSummary = mAdapter.getRoomSummaryAt(groupPosition, childPosition); final MXSession session = Matrix.getInstance(HomeActivity.this) .getSession(roomSummary.getMatrixId()); String roomId = roomSummary.getRoomId(); Room room = session.getDataHandler().getRoom(roomId); if (null != room) { room.leave(new SimpleApiCallback<Void>(HomeActivity.this) { @Override public void onSuccess(Void info) { mAdapter.removeRoomSummary(groupPosition, roomSummary); mAdapter.notifyDataSetChanged(); } }); } } }); } } }); fragment.show(fm, TAG_FRAGMENT_ROOM_OPTIONS); return true; } } return false; } }); mMyRoomList.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { if (mAdapter.isPublicsGroupIndex(groupPosition)) { refreshPublicRoomsList(); } } }); mMyRoomList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { return mAdapter.getGroupCount() < 2; } }); mSearchRoomEditText = (EditText) this.findViewById(R.id.editText_search_room); mSearchRoomEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(android.text.Editable s) { mAdapter.setSearchedPattern(s.toString()); mMyRoomList.smoothScrollToPosition(0); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); }
From source file:com.fvd.nimbus.PaintActivity.java
/** Called when the activity is first created. */ @Override//ww w . java 2 s .co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); try { requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception e) { e.printStackTrace(); } ctx = this; prefs = PreferenceManager.getDefaultSharedPreferences(this); dWidth = prefs.getInt("dWidth", 2); fWidth = prefs.getInt("fWidth", 1); dColor = prefs.getInt(pColor, Color.RED); saveFormat = Integer.parseInt(prefs.getString("saveFormat", "1")); serverHelper.getInstance().setCallback(this, this); serverHelper.getInstance().setMode(saveFormat); setContentView(R.layout.screen_edit); drawer = (DrawerLayout) findViewById(R.id.root); findViewById(R.id.bDraw1).setOnClickListener(this); findViewById(R.id.bDraw2).setOnClickListener(this); findViewById(R.id.bDraw3).setOnClickListener(this); findViewById(R.id.bDraw4).setOnClickListener(this); findViewById(R.id.bDraw5).setOnClickListener(this); findViewById(R.id.bDraw6).setOnClickListener(this); findViewById(R.id.bDraw8).setOnClickListener(this); findViewById(R.id.bColor1).setOnClickListener(this); findViewById(R.id.bColor2).setOnClickListener(this); findViewById(R.id.bColor3).setOnClickListener(this); findViewById(R.id.bColor4).setOnClickListener(this); findViewById(R.id.bColor5).setOnClickListener(this); paletteButton = (CircleButton) findViewById(R.id.bToolColor); paletteButton.setOnClickListener(this); paletteButton_land = (CircleButton) findViewById(R.id.bToolColor_land); //paletteButton_land.setOnClickListener(this); ((SeekBar) findViewById(R.id.seekBarLine)).setProgress(dWidth * 10); ((SeekBar) findViewById(R.id.seekBarType)).setProgress(fWidth * 10); ((TextView) findViewById(R.id.tvTextType)).setText(String.format("%d", 40 + fWidth * 20)); findViewById(R.id.bUndo).setOnClickListener(this); findViewById(R.id.btnBack).setOnClickListener(this); findViewById(R.id.bClearAll).setOnClickListener(this); findViewById(R.id.bTurnLeft).setOnClickListener(this); findViewById(R.id.bTurnRight).setOnClickListener(this); findViewById(R.id.bDone).setOnClickListener(this); findViewById(R.id.bApplyText).setOnClickListener(this); ((ImageButton) findViewById(R.id.bStroke)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { v.setSelected(!v.isSelected()); } }); lineWidthListener = new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub if (true || fromUser) { /*dWidth = (progress/10); drawView.setWidth((dWidth+1)*5);*/ dWidth = progress; drawView.setWidth(dWidth); Editor e = prefs.edit(); e.putInt("dWidth", dWidth); e.commit(); } } }; ((SeekBar) findViewById(R.id.seekBarLine)).setOnSeekBarChangeListener(lineWidthListener); ((SeekBar) findViewById(R.id.ls_seekBarLine)).setOnSeekBarChangeListener(lineWidthListener); fontSizeListener = new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub if (fromUser) { fWidth = progress / 10; int c = 40 + fWidth * 20; drawView.setFontSize(c); Editor e = prefs.edit(); e.putInt("fWidth", fWidth); e.commit(); try { ((TextView) findViewById(R.id.tvTextType)).setText(String.format("%d", c)); ((TextView) findViewById(R.id.ls_tvTextType)).setText(String.format("%d", c)); } catch (Exception ex) { } } } }; ((SeekBar) findViewById(R.id.seekBarType)).setOnSeekBarChangeListener(fontSizeListener); ((SeekBar) findViewById(R.id.ls_seekBarType)).setOnSeekBarChangeListener(fontSizeListener); drawView = (DrawView) findViewById(R.id.painter); drawView.setWidth((dWidth + 1) * 5); drawView.setFontSize(40 + fWidth * 20); setBarConfig(getResources().getConfiguration().orientation); findViewById(R.id.bEditPage).setOnClickListener(this); findViewById(R.id.bToolColor).setOnClickListener(this); findViewById(R.id.bErase).setOnClickListener(this); findViewById(R.id.bToolShape).setOnClickListener(this); findViewById(R.id.bToolText).setOnClickListener(this); findViewById(R.id.bToolCrop).setOnClickListener(this); findViewById(R.id.btnBack).setOnClickListener(this); findViewById(R.id.bDone).setOnClickListener(this); findViewById(R.id.btnShare).setOnClickListener(this); findViewById(R.id.bSave2SD).setOnClickListener(this); findViewById(R.id.bSave2Nimbus).setOnClickListener(this); userMail = prefs.getString("userMail", ""); userPass = prefs.getString("userPass", ""); sessionId = prefs.getString("sessionId", ""); appSettings.sessionId = sessionId; appSettings.userMail = userMail; appSettings.userPass = userPass; storePath = ""; Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); //storePath= intent.getPackage().getClass().toString(); if ((Intent.ACTION_VIEW.equals(action) || Intent.ACTION_SEND.equals(action) || "com.onebit.nimbusnote.EDIT_PHOTO".equals(action)) && type != null) { if (type.startsWith("image/")) { Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri == null) imageUri = intent.getData(); if (imageUri != null) { String url = Uri.decode(imageUri.toString()); if (url.startsWith(CONTENT_PHOTOS_URI_PREFIX)) { url = getPhotosPhotoLink(url); } //else url=Uri.decode(url); ContentResolver cr = getContentResolver(); InputStream is; try { is = cr.openInputStream(Uri.parse(url)); if ("com.onebit.nimbusnote.EDIT_PHOTO".equals(action)) storePath = " ";//getGalleryPath(Uri.parse(url)); Bitmap bmp = BitmapFactory.decodeStream(is); if (bmp.getWidth() != -1 && bmp.getHeight() != -1) drawView.setBitmap(bmp, 0); } catch (Exception e) { appSettings.appendLog("paint:onCreate " + e.getMessage()); } } } } else { String act = getIntent().getExtras().getString("act"); if ("photo".equals(act)) { getPhoto(); } else if ("picture".equals(act)) { getPicture(); } else { String filePath = getIntent().getExtras().getString("path"); boolean isTemp = getIntent().getExtras().getBoolean("temp"); domain = getIntent().getExtras().getString("domain"); if (domain == null) domain = serverHelper.getDate(); if (filePath.contains("://")) { Bitmap bmp = helper.LoadImageFromWeb(filePath); if (bmp != null) { drawView.setBitmap(bmp, 0); } } else { File file = new File(filePath); if (file.exists()) { try { int orient = helper.getOrientationFromExif(filePath); Bitmap bmp = helper.decodeSampledBitmap(filePath, 1000, 1000); if (bmp != null) { drawView.setBitmap(bmp, orient); } } catch (Exception e) { appSettings.appendLog("paint.onCreate() " + e.getMessage()); } if (isTemp) file.delete(); } } } } drawView.setBackgroundColor(Color.WHITE); drawView.requestFocus(); drawView.setColour(dColor); setPaletteColor(dColor); drawView.setSelChangeListener(new shapeSelectionListener() { @Override public void onSelectionChanged(int shSize, int fSize, int shColor) { setSelectedFoot(0); setLandToolSelected(R.id.bEditPage_land); //updateColorDialog(shSize!=-1?(shSize/5)-1:dWidth, fSize!=-1?(fSize-40)/20:fWidth, shColor!=0?colorToId(shColor):dColor); dColor = shColor; ccolor = shColor; int sw = shSize != -1 ? shSize : dWidth; canChange = false; ((SeekBar) findViewById(R.id.seekBarLine)).setProgress(sw); ((SeekBar) findViewById(R.id.ls_seekBarLine)).setProgress(sw); setPaletteColor(dColor); drawView.setColour(dColor); canChange = true; } @Override public void onTextChanged(String text, boolean stroke) { if (findViewById(R.id.text_field).getVisibility() != View.VISIBLE) { hideTools(); findViewById(R.id.bStroke).setSelected(stroke); ((EditText) findViewById(R.id.etEditorText)).setText(text); findViewById(R.id.text_field).setVisibility(View.VISIBLE); findViewById(R.id.etEditorText).requestFocus(); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .showSoftInput(findViewById(R.id.etEditorText), 0); findViewById(R.id.bToolText).postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub setSelectedFoot(2); } }, 100); } } }); setColorButtons(dColor); //mPlanetTitles = getResources().getStringArray(R.array.lmenu_paint); /*ListView listView = (ListView) findViewById(R.id.left_drawer); listView.setAdapter(new DrawerMenuAdapter(this,getResources().getStringArray(R.array.lmenu_paint))); listView.setOnItemClickListener(this);*/ }
From source file:com.android.documentsui.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;//from ww w.j av a 2 s .c o m } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_MANAGE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = virtualIntent; final String action = intent.getAction(); if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;/*from ww w .j av a2 s . c om*/ } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_MANAGE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
/** * Parses the intent//from w w w. java 2s . c o m */ private void parseIntent(Intent intent) { final String action = intent.getAction(); final String type = intent.getType(); if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action) || Intent.ACTION_PICK.equals(action) && type != null) { // Post event //newFileToOpen(new File(intent // .getData().getPath()), ""); Uri uri = intent.getData(); GreatUri newUri = new GreatUri(uri, AccessStorageApi.getPath(this, uri), AccessStorageApi.getName(this, uri)); newFileToOpen(newUri, ""); } else if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), intent.getStringExtra(Intent.EXTRA_TEXT)); } } }
From source file:org.kontalk.ui.ComposeMessage.java
private Bundle processIntent(Bundle savedInstanceState) { Intent intent; if (savedInstanceState != null) { mLostFocus = savedInstanceState.getBoolean("lostFocus"); Uri uri = savedInstanceState.getParcelable(Uri.class.getName()); if (uri == null) { Log.d(TAG, "restoring non-loaded conversation, aborting"); finish();// www . j a va 2 s . c o m return null; } intent = new Intent(ACTION_VIEW_USERID, uri); } else { intent = getIntent(); } if (intent != null) { final String action = intent.getAction(); Bundle args = null; // view intent // view conversation - just threadId provided // view conversation - just userId provided if (Intent.ACTION_VIEW.equals(action) || ACTION_VIEW_CONVERSATION.equals(action) || ACTION_VIEW_USERID.equals(action)) { Uri uri = intent.getData(); // two-panes UI: start conversation list if (Kontalk.hasTwoPanesUI(this)) { Intent startIntent = new Intent(action, uri, getApplicationContext(), ConversationsActivity.class); startActivity(startIntent); // no need to go further finish(); return null; } // single-pane UI: start normally else { args = new Bundle(); args.putString("action", action); args.putParcelable("data", uri); args.putLong(EXTRA_MESSAGE, intent.getLongExtra(EXTRA_MESSAGE, -1)); args.putString(EXTRA_HIGHLIGHT, intent.getStringExtra(EXTRA_HIGHLIGHT)); args.putBoolean(EXTRA_CREATING_GROUP, intent.getBooleanExtra(EXTRA_CREATING_GROUP, false)); } } // send external content else if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { sendIntent = intent; String mime = intent.getType(); Log.i(TAG, "sending data to someone: " + mime); chooseContact(); // onActivityResult will handle the rest return null; } // send to someone else if (Intent.ACTION_SENDTO.equals(action)) { try { Uri uri = intent.getData(); // a phone number should come here... String number = NumberValidator.fixNumber(this, uri.getSchemeSpecificPart(), Authenticator.getDefaultAccountName(this), 0); // compute hash and open conversation String jid = XMPPUtils.createLocalJID(this, MessageUtils.sha1(number)); // two-panes UI: start conversation list if (Kontalk.hasTwoPanesUI(this)) { Intent startIntent = new Intent(getApplicationContext(), ConversationsActivity.class); startIntent.setAction(ACTION_VIEW_USERID); startIntent.setData(Threads.getUri(jid)); startActivity(startIntent); // no need to go further finish(); return null; } // single-pane UI: start normally else { args = new Bundle(); args.putString("action", ComposeMessage.ACTION_VIEW_USERID); args.putParcelable("data", Threads.getUri(jid)); args.putString("number", number); } } catch (Exception e) { Log.e(TAG, "invalid intent", e); finish(); } } return args; } return null; }
From source file:dev.dworks.apps.anexplorer.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = getIntent(); final String action = intent.getAction(); if (IntentUtils.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;// w ww . j a va2 s. c o m } else if (IntentUtils.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { //mState.action = ACTION_MANAGE; mState.action = ACTION_BROWSE; } else { mState.action = ACTION_BROWSE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(IntentUtils.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_GET_CONTENT || mState.action == ACTION_BROWSE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(IntentUtils.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(IntentUtils.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, true); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); mState.rootMode = SettingsActivity.getRootMode(this); }
From source file:org.tomahawk.tomahawk_android.activities.TomahawkMainActivity.java
private void handleIntent(Intent intent) { if (SHOW_PLAYBACKFRAGMENT_ON_STARTUP.equals(intent.getAction())) { // if this Activity is being shown after the user clicked the notification if (mSlidingUpPanelLayout != null) { mSlidingUpPanelLayout.expandPanel(); }/*from w ww. j a va2 s.c o m*/ } if (intent.hasExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE)) { Bundle bundle = new Bundle(); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC_SMALL); FragmentUtils.replace(this, PreferencePagerFragment.class, bundle); } if (intent.getData() != null) { final Uri data = intent.getData(); intent.setData(null); List<String> pathSegments = data.getPathSegments(); String host = data.getHost(); String scheme = data.getScheme(); if ((scheme != null && (scheme.equals("spotify") || scheme.equals("tomahawk"))) || (host != null && (host.contains("spotify.com") || host.contains("hatchet.is") || host.contains("toma.hk") || host.contains("beatsmusic.com") || host.contains("deezer.com") || host.contains("rdio.com") || host.contains("soundcloud.com")))) { PipeLine.get().lookupUrl(data.toString()); } else if ((pathSegments != null && pathSegments.get(pathSegments.size() - 1).endsWith(".xspf")) || (intent.getType() != null && intent.getType().equals("application/xspf+xml"))) { TomahawkRunnable r = new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_HIGH) { @Override public void run() { Playlist pl = XspfParser.parse(data); if (pl != null) { final Bundle bundle = new Bundle(); bundle.putString(TomahawkFragment.PLAYLIST, pl.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } }); } } }; ThreadManager.get().execute(r); } else if (pathSegments != null && (pathSegments.get(pathSegments.size() - 1).endsWith(".axe") || pathSegments.get(pathSegments.size() - 1).endsWith(".AXE"))) { InstallPluginConfigDialog dialog = new InstallPluginConfigDialog(); Bundle args = new Bundle(); args.putString(InstallPluginConfigDialog.PATH_TO_AXE_URI_STRING, data.toString()); dialog.setArguments(args); dialog.show(getSupportFragmentManager(), null); } else { String albumName; String trackName; String artistName; try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(this, data); albumName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM); artistName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); trackName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); retriever.release(); } catch (Exception e) { Log.e(TAG, "handleIntent: " + e.getClass() + ": " + e.getLocalizedMessage()); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { String msg = TomahawkApp.getContext().getString(R.string.invalid_file); Toast.makeText(TomahawkApp.getContext(), msg, Toast.LENGTH_LONG).show(); } }); return; } if (TextUtils.isEmpty(trackName) && pathSegments != null) { trackName = pathSegments.get(pathSegments.size() - 1); } Query query = Query.get(trackName, albumName, artistName, false); Result result = Result.get(data.toString(), query.getBasicTrack(), UserCollectionStubResolver.get()); float trackScore = query.howSimilar(result); query.addTrackResult(result, trackScore); Bundle bundle = new Bundle(); List<Query> queries = new ArrayList<>(); queries.add(query); Playlist playlist = Playlist.fromQueryList(TomahawkMainActivity.getSessionUniqueStringId(), false, "", "", queries); bundle.putString(TomahawkFragment.PLAYLIST, playlist.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } } }