/** * In order to update notification from the AlarmSender. * * @param oldName <code>String</code> - old name * @param oldDescription <code>String</code> - old description * @param oldDate <code>String</code> - old date * @param newName <code>String</code> - new name * @param newDescription <code>String</code> - new description * @param newDate <code>String</code> - new date */ @android.webkit.JavascriptInterface public void updateAlarmPerToDoItem( String oldName, String oldDescription, String oldDate, String newName, String newDescription, String newDate) { long oldTime = ParseDateToTimeStamp(oldDate); Intent oldIntent = new Intent(MainActivity.this, NotificationService.class); oldIntent.putExtra("name", oldName); oldIntent.putExtra("description", oldDescription); oldIntent.putExtra("time", oldTime); int oldId = (oldName + oldDescription + oldTime).hashCode(); oldIntent.setData(Uri.parse(String.valueOf(oldId))); PendingIntent oldPendingIntent = PendingIntent.getService( MainActivity.this, 0, oldIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.cancel(oldPendingIntent); long newTime = ParseDateToTimeStamp(newDate); Intent newIntent = new Intent(MainActivity.this, NotificationService.class); oldIntent.putExtra("name", newName); oldIntent.putExtra("description", newDescription); oldIntent.putExtra("time", newTime); int newId = (newName + newDescription + newTime).hashCode(); newIntent.setData(Uri.parse(String.valueOf(newId))); PendingIntent newPendingIntent = PendingIntent.getService( MainActivity.this, 0, newIntent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.set(AlarmManager.RTC_WAKEUP, newTime, newPendingIntent); }
/** 2nd */ private void playVideoOrDownload() { Log.d("INSIDE playVideoOrDownload", "INSIDE playVideoOrDownload"); try { if (streamMode) { // seekBar.setSecondaryProgress(seekBar.getMax()); this.startVideo(Uri.parse(embedUrlStr)); } else { if (this.isOnline() && (!tempFile.exists() || (tempFile.exists() && tempFile.length() == 0L))) { this.downloadThread = new VideoDownloader(this.embedUrlStr, this.pathToFile, this.tempFile, this); this.downloadThread.start(); // if (!videoView.isPlaying()) // startVideo(Uri.parse(embedUrlStr)); } else if (!this.isOnline() && !tempFile.exists()) { this.showErrorAlert( getString(R.string.error_message_title), getString(R.string.error_no_connection)); } if (tempFile.exists() && tempFile.length() > 0) { Log.d("Start VIDEO with PATH", this.pathToFile); seekBar.setSecondaryProgress(seekBar.getMax()); this.startVideo(Uri.parse("file:/" + this.pathToFile)); } } } catch (Exception e) { Log.e("TAG", "error: " + e.getMessage(), e); if (videoView != null) { videoView.stopPlayback(); } } }
@Override public void onClick(View v) { if (entry == null) { return; } switch (entry.getState()) { case ThemeEntry.STATE_UNINSTALLED: Uri uri = Uri.parse("market://search?q=pname:" + entry.getPackageName()); Intent intent = new Intent(Intent.ACTION_VIEW, uri); try { v.getContext().startActivity(intent); } catch (ActivityNotFoundException e) { uri = Uri.parse(entry.getFileUrl()); intent.setData(uri); v.getContext().startActivity(intent); } break; case ThemeEntry.STATE_INSTALLED: useTheme(v.getContext()); break; case ThemeEntry.STATE_USING: break; } }
public static void PublishUnreadCount(Context context) { try { // Check if TeslaUnread is installed before doing some expensive database query ContentValues cv = new ContentValues(); cv.put("tag", "de.luhmer.owncloudnewsreader/de.luhmer.owncloudnewsreader"); cv.put("count", 0); context .getContentResolver() .insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); // If we get here.. TeslaUnread is installed DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context); int count = Integer.parseInt( dbConn.getUnreadItemsCountForSpecificFolder( SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS)); cv.put("count", count); context .getContentResolver() .insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); } catch (IllegalArgumentException ex) { /* Fine, TeslaUnread is not installed. */ } catch (Exception ex) { /* Some other error, possibly because the format of the ContentValues are incorrect. Log but do not crash over this. */ ex.printStackTrace(); } }
private void share() { QRCodeEncoder encoder = qrCodeEncoder; if (encoder == null) { // Odd Log.w(TAG, "No existing barcode to send?"); return; } String contents = encoder.getContents(); if (contents == null) { Log.w(TAG, "No existing barcode to send?"); return; } Bitmap bitmap; try { bitmap = encoder.encodeAsBitmap(); } catch (WriterException we) { Log.w(TAG, we); return; } if (bitmap == null) { return; } File bsRoot = new File(Environment.getExternalStorageDirectory(), "BarcodeScanner"); File barcodesRoot = new File(bsRoot, "Barcodes"); if (!barcodesRoot.exists() && !barcodesRoot.mkdirs()) { Log.w(TAG, "Couldn't make dir " + barcodesRoot); showErrorMessage(R.string.msg_unmount_usb); return; } File barcodeFile = new File(barcodesRoot, makeBarcodeFileName(contents) + ".png"); barcodeFile.delete(); FileOutputStream fos = null; try { fos = new FileOutputStream(barcodeFile); bitmap.compress(Bitmap.CompressFormat.PNG, 0, fos); } catch (FileNotFoundException fnfe) { Log.w(TAG, "Couldn't access file " + barcodeFile + " due to " + fnfe); showErrorMessage(R.string.msg_unmount_usb); return; } finally { if (fos != null) { try { fos.close(); } catch (IOException ioe) { // do nothing } } } Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.putExtra( Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " - " + encoder.getTitle()); intent.putExtra(Intent.EXTRA_TEXT, contents); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + barcodeFile.getAbsolutePath())); intent.setType("image/png"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(Intent.createChooser(intent, null)); }
@Override public void onInfoWindowClick(Marker marker) { switch (marker.getTitle()) { case "Indicative": { Intent indIntent = new Intent(Intent.ACTION_VIEW); indIntent.setData(Uri.parse(indURL)); startActivity(indIntent); } break; case "Zirka": { Intent zirIntent = new Intent(Intent.ACTION_VIEW); zirIntent.setData(Uri.parse(zirURL)); startActivity(zirIntent); } break; case "Hydrosila": { Intent hydIntent = new Intent(Intent.ACTION_VIEW); hydIntent.setData(Uri.parse(hydURL)); startActivity(hydIntent); } break; } }
public Uri getWebdavUri() { if (mCredentials instanceof OwnCloudBearerCredentials) { return Uri.parse(mBaseUri + AccountUtils.ODAV_PATH); } else { return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_4_0); } }
private void loadImage(IdentifyLicense entity) { if (!UIUtils.isEmpty(entity.getIdentifyImage())) { Glide.with(context) .load(Uri.parse(entity.getIdentifyImage())) .placeholder(R.mipmap.icon_pic_loading) .error(R.mipmap.icon_pic_load_fail) .listener(new ImageLoaderListener(context, Uri.parse(entity.getIdentifyImage()))) .into((ImageView) identity_card_verify_view.findViewById(R.id.iv_identity_card_face)); ((TextView) identity_card_verify_view.findViewById(R.id.tv_face_2)).setText("上传成功,点击图片可重新上传"); } else { Glide.with(context) .load(R.mipmap.identity_card_face) .listener(new ImageLoaderListener(context, null)) .into((ImageView) identity_card_verify_view.findViewById(R.id.iv_identity_card_face)); ((TextView) identity_card_verify_view.findViewById(R.id.tv_face_2)).setText("点击上传"); } if (!UIUtils.isEmpty(entity.getIdentifyBackImage())) { Glide.with(context) .load(Uri.parse(entity.getIdentifyBackImage())) .placeholder(R.mipmap.icon_pic_loading) .error(R.mipmap.icon_pic_load_fail) .listener(new ImageLoaderListener(context, Uri.parse(entity.getIdentifyBackImage()))) .into((ImageView) identity_card_verify_view.findViewById(R.id.iv_identity_card_back)); ((TextView) identity_card_verify_view.findViewById(R.id.tv_back_2)).setText("上传成功,点击图片可重新上传"); } else { Glide.with(context) .load(R.mipmap.identity_card_back) .listener(new ImageLoaderListener(context, null)) .into((ImageView) identity_card_verify_view.findViewById(R.id.iv_identity_card_back)); ((TextView) identity_card_verify_view.findViewById(R.id.tv_back_2)).setText("点击上传"); } }
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // update each of the widgets with the remote adapter for (int i = 0; i < appWidgetIds.length; ++i) { // Here we setup the intent which points to the StackViewService which will // provide the views for this collection. Intent intent = new Intent(context, StackWidgetService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]); // When intents are compared, the extras are ignored, so we need to embed the extras // into the data so that the extras will not be ignored. intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout); rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent); // The empty view is displayed when the collection has no items. It should be a sibling // of the collection view. rv.setEmptyView(R.id.stack_view, R.id.empty_view); // Here we setup the a pending intent template. Individuals items of a collection // cannot setup their own pending intents, instead, the collection as a whole can // setup a pending intent template, and the individual items can set a fillInIntent // to create unique before on an item to item basis. Intent toastIntent = new Intent(context, StackWidgetProvider.class); toastIntent.setAction(StackWidgetProvider.TOAST_ACTION); toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent); appWidgetManager.updateAppWidget(appWidgetIds[i], rv); } super.onUpdate(context, appWidgetManager, appWidgetIds); }
public boolean mkdir() throws IOException { if (file.exists()) { return file.isDirectory(); } File tmpFile = new File(file, ".MediaWriteTemp"); int albumId = getTemporaryAlbumId(); if (albumId == 0) { throw new IOException("Fail"); } Uri albumUri = Uri.parse(ALBUM_ART_URI + '/' + albumId); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, tmpFile.getAbsolutePath()); if (contentResolver.update(albumUri, values, null, null) == 0) { values.put(MediaStore.Audio.AlbumColumns.ALBUM_ID, albumId); contentResolver.insert(Uri.parse(ALBUM_ART_URI), values); } try { ParcelFileDescriptor fd = contentResolver.openFileDescriptor(albumUri, "r"); fd.close(); } finally { MediaFile tmpMediaFile = new MediaFile(context, tmpFile); tmpMediaFile.delete(); } return file.exists(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.github: startActivity( new Intent( "android.intent.action.VIEW", Uri.parse("https://github.com/diogobernardino/WilliamChart"))); return true; case R.id.play: try { startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse( "market://details?id=" + this.getApplicationContext().getPackageName()))); } catch (ActivityNotFoundException e) { startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse( "http://play.google.com/store/apps/details?id=" + "https://play.google.com/store/apps/details?id=com.db.williamchartdemo"))); } return true; default: return super.onOptionsItemSelected(item); } }
public void signup(LoginResultListener paramLoginResultListener) { Intent localIntent = new Intent("android.intent.action.VIEW"); if (ConfigHelper.disableweblogin) { localIntent.setData(Uri.parse("dianping://signup")); localIntent.setFlags(335544320); this.context.startActivity(localIntent); this.loginResultListener = paramLoginResultListener; return; } String str2 = LoginUtils.getLoginGASource(this.context); String str3 = Environment.versionName(); String str4 = Environment.mapiUserAgent(); String str5 = preferences(DPApplication.instance()).getString("dpid", ""); Object localObject = DPApplication.instance().locationService().location(); String str1; if (localObject != null) str1 = Location.FMT.format(((DPObject)localObject).getDouble("Lat")); for (localObject = Location.FMT.format(((DPObject)localObject).getDouble("Lng")); ; localObject = "0") { localIntent.setData(Uri.parse("dianping://loginweb?url=http://m.dianping.com/reg/mobile/app&version=" + str3 + "&agent=" + str4 + "&dpid=" + str5 + "&gasource=" + str2 + "&lat=" + str1 + "&lng=" + (String)localObject)); break; str1 = "0"; } }
/** * Open a YouTube video. If the app is not installed, it opens it in the browser * * @param videoId The video ID * @return the intent */ public static Intent newPlayYouTubeVideoIntent(String videoId) { try { return new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId)); } catch (ActivityNotFoundException ex) { return new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + videoId)); } }
@Override protected void onListItemClick(ListView l, View v, int position, long id) { Intent intent; switch (position) { default: case 0: intent = new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.okbu.edu/admissions/onlineapp.html")); break; case 2: intent = new Intent(this, Majors.class); break; case 3: intent = new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.okbu.edu/admissions/moreinfo.html")); break; case 4: intent = new Intent(this, Visitwebview.class); break; /*case 5 : intent = new Intent(this, Getinvolved.class); break;*/ } startActivity(intent); };
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: // Launch Navigation to the conference site Intent i = new Intent( android.content.Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_map_place))); startActivity(i); break; case 1: // Display the Open Source projects used for this application Intent i1 = new Intent(getApplicationContext(), LibsActivity.class); i1.putExtra(Libs.BUNDLE_FIELDS, Libs.toStringArray(R.string.class.getFields())); i1.putExtra(Libs.BUNDLE_LIBS, new String[] {"OpenCSV", "PrettySharedPreferences"}); i1.putExtra(Libs.BUNDLE_VERSION, true); i1.putExtra(Libs.BUNDLE_LICENSE, true); i1.putExtra(Libs.BUNDLE_TITLE, "Open Source"); i1.putExtra(Libs.BUNDLE_THEME, R.style.AppThemeBar); startActivity(i1); break; case 2: // Open my twitter ;) Intent i2 = new Intent(Intent.ACTION_VIEW); i2.setData(Uri.parse("http://twitter.com/Tajchert")); startActivity(i2); break; case 3: // Open the feedback form Intent i3 = new Intent(Intent.ACTION_VIEW); i3.setData(Uri.parse(getString(R.string.url_feedback_form))); startActivity(i3); break; } }
public void isSong(Context context, String type) { Uri ringToneUri = null; if (type.equals("mb_normal")) { System.out.println("isnew==============="); ringToneUri = Uri.parse("android.resource://com.citi.mc/" + R.raw.msg); } else if (type.equals("mobile_online")) { System.out.println("isonline======================="); ringToneUri = Uri.parse("android.resource://com.citi.mc/" + R.raw.online); } if (type.equals("mb_system")) { System.out.println("isnew==============="); ringToneUri = Uri.parse("android.resource://com.citi.mc/" + R.raw.system); } try { sPhelper = new SPhelper(context); MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource(context, ringToneUri); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setOnPreparedListener(new MediaLIstener()); mediaPlayer.prepareAsync(); } catch (Exception e) { e.printStackTrace(); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View myView = inflater.inflate(R.layout.contentp_fragment, container, false); // get the one view I need. output = (TextView) myView.findViewById(R.id.TextView01); appendthis("Query for 2 square"); // example, select one of them, in this case 2 Uri onerow = Uri.parse("content://edu.cs4730.provider/square/2"); Cursor c = getActivity().getContentResolver().query(onerow, null, null, null, null); if (c != null) { c.moveToFirst(); do { Log.i(TAG, "Value is" + c.getString(0)); appendthis(c.getString(0) + " value is " + c.getString(1)); } while (c.moveToNext()); } appendthis("\nQuery all for cube:"); // now select "all", which will return 1 to 10 cubed. Uri allrow = Uri.parse("content://edu.cs4730.provider/cube"); c = getActivity().getContentResolver().query(allrow, null, null, null, null); if (c != null) { c.moveToFirst(); do { Log.i(TAG, "Value is " + c.getString(0)); appendthis(c.getString(0) + " value is " + c.getString(1)); } while (c.moveToNext()); } return myView; }
/** * Set the user associated URIs * * @param uris List of URIs */ public void setAssociatedUri(ListIterator<Header> uris) { if (uris == null) { return; } String sipUri = null; String telUri = null; while (uris.hasNext()) { ExtensionHeader header = (ExtensionHeader) uris.next(); String value = header.getValue(); value = SipUtils.extractUriFromAddress(value); if (value.startsWith(PhoneUtils.SIP_URI_HEADER)) { sipUri = value; } else if (value.startsWith(PhoneUtils.TEL_URI_HEADER)) { telUri = value; } } if ((sipUri != null) && (telUri != null)) { mPreferred = Uri.parse(telUri); } else if (telUri != null) { mPreferred = Uri.parse(telUri); } else if (sipUri != null) { mPreferred = Uri.parse(sipUri); } }
// Locates the position of the radio button and executes the correct action // depending on its location. protected void onListItemClick(ListView l, View v, int position, long id) { switch (position) { // Action when Perseus Constellation selected case 0: startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.go-astronomy.com/constellations.php?Name=Perseus"))); break; // Action when Taurus Constellation is selected case 1: startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.go-astronomy.com/constellations.php?Name=Taurus"))); break; // Action when Hydra Constellation is selected case 2: startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.go-astronomy.com/constellations.php?Name=Orion"))); break; // Action when Dorado Constellation is selected case 3: startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.go-astronomy.com/constellations.php?Name=Dorado"))); break; } }
/* Handles item selections */ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.MenuItemShowHelp: String targetURL = getString(R.string.AboutZipSignerDocUrl); Intent wsi = new Intent(Intent.ACTION_VIEW, Uri.parse(targetURL)); startActivity(wsi); return true; case R.id.MenuItemDonate: String donateURL = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=24Y8S9UH5ETRU"; Intent di = new Intent(Intent.ACTION_VIEW, Uri.parse(donateURL)); startActivity(di); return true; case R.id.MenuItemManageKeys: // Launch the ZipSignerActivity to perform the signature operation. Intent mki = new Intent("kellinwood.zipsigner.action.MANAGE_KEYS"); // Activity is started and the result is returned via a call to onActivityResult(), below. startActivityForResult(mki, REQUEST_CODE_MANAGE_KEYS); return true; case R.id.MenuItemAbout: AboutDialog.show(this); return true; } return false; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent intent = getIntent(); Uri uri = intent.getData(); if (uri != null) { MainActivity.addLink(this, uri.toString()); Uri newUri = Uri.parse("view-source:" + uri.toString()); startChrome(newUri); } if (Intent.ACTION_SEND.equals(intent.getAction())) { Bundle extras = intent.getExtras(); if (extras != null) { String text = extras.getString(Intent.EXTRA_TEXT); Pattern pattern = Pattern.compile(URL_PATTERN); if (text != null) { Matcher m = pattern.matcher(text); if (m.find()) { String url = m.group(1); MainActivity.addLink(this, url); Uri newUri = Uri.parse("view-source:" + url); startChrome(newUri); } } } } this.finish(); }
@Override public void onReceive(Context context, Intent intent) { Session current = Session.getInstance(); ContentResolver resolver = context.getContentResolver(); ContentValues values = new ContentValues(); values.clear(); boolean isLogin = intent.getBooleanExtra("LoginState", false); try { if (isLogin) { current.isLogin(true); current.setServer(intent.getStringExtra("Server")); current.setCookie(intent.getStringExtra("Cookie")); values.put("Server", intent.getStringExtra("Server")); values.put("Cookie", intent.getStringExtra("Cookie")); resolver.update(Uri.parse(GlobalConst.CONTENT_SESSION_URI), values, null, null); } else { current.isLogin(false); current.setServer(""); current.setCookie(""); values.put("Server", ""); values.put("Cookie", ""); resolver.update(Uri.parse(GlobalConst.CONTENT_SESSION_URI), values, null, null); } } catch (IllegalArgumentException e) { current.isLogin(false); current.setServer(""); current.setCookie(""); } }
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { Log.d(TAG, "updateAppWidget ID:" + appWidgetId); boolean isContentProviderInstalled = isPackageInstalled(CONTENT_PROVIDER_PACKAGE, context); /* Log.d(TAG, "is On This Day installed:"+isContentProviderInstalled); Log.d(TAG, "is ContentProviderInstalled:"+DataFetcher.isProviderInstalled(context)); */ // save current Lang Resources res = context.getResources(); Configuration conf = res.getConfiguration(); String currentLang = conf.locale.getLanguage(); // get settings lang String settingLang = SettingsActivity.loadPrefs(context, appWidgetId); if (settingLang == null || settingLang.isEmpty()) { settingLang = currentLang; } Date currentDate = new Date(); RemoteViews rv; if (!isContentProviderInstalled) { // no content provider rv = new RemoteViews(context.getPackageName(), R.layout.plz_install_widget_layout); // Create an Intent to launch Play Market Intent intent; // TODO check is market:// parsed try { intent = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=" + CONTENT_PROVIDER_PACKAGE)); } catch (android.content.ActivityNotFoundException anfe) { intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "https://play.google.com/store/apps/details?id=" + CONTENT_PROVIDER_PACKAGE)); } PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); rv.setOnClickPendingIntent(R.id.installView, pendingIntent); } else { rv = new RemoteViews(context.getPackageName(), R.layout.atd_widget_layout); setTitle(rv, context, settingLang, currentDate); // start service for getData and create Views setList(rv, context, settingLang, currentDate, appWidgetId); } // // Do additional processing specific to this app widget... // appWidgetManager.updateAppWidget(appWidgetId, rv); }
@Override public void onItemClick(AdapterView<?> adapter, View arg1, int position, long id) { if (contents.get(position).type == Profile.Type.WEBPAGE) { final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(contents.get(position).content)); startActivity(browserIntent); } else if (contents.get(position).type == Profile.Type.ROOM) { final Intent i = new Intent(getActivity(), ProfileActivity.class); i.putExtra(ProfileActivity.PROFILE_TYPE, ProfileActivity.PROFILE_ROOM); final String roomName = contents.get(position).content; for (Room room : me.getRooms()) { if (room.getAcronym().equals(roomName)) { i.putExtra(ProfileActivity.PROFILE_CODE, room.getId()) .putExtra(Intent.EXTRA_TITLE, contents.get(position).content); break; } } startActivity(i); } else if (contents.get(position).type == Profile.Type.EMAIL) { final Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] {contents.get(position).content}); startActivity(Intent.createChooser(i, getString(R.string.profile_choose_email_app))); } else if (contents.get(position).type == Profile.Type.MOBILE) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + contents.get(position).content)); startActivity(callIntent); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.main); uris.clear(); uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_1-4.mp4")); uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_2-4.mp4")); uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_3-4.mp4")); uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_4-4.mp4")); // WindowManager.LayoutParams params = new WindowManager.LayoutParams(); // params.buttonBrightness = 0; // view.setLayoutParams(params); VideoView view = (VideoView) findViewById(R.id.videoView1); view.setOnCompletionListener( new OnCompletionListener() { public void onCompletion(MediaPlayer player) { syncVideo(); } }); syncVideo(); }
/* Scan the files in the new directory, and store them in the filelist. * Update the UI by refreshing the list adapter. */ private void loadDirectory(String newdirectory) { if (newdirectory.equals("../")) { try { directory = new File(directory).getParent(); } catch (Exception e) { } } else { directory = newdirectory; } SharedPreferences.Editor editor = getPreferences(0).edit(); editor.putString("lastBrowsedDirectory", directory); editor.commit(); directoryView.setText(directory); filelist = new ArrayList<FileUri>(); ArrayList<FileUri> sortedDirs = new ArrayList<FileUri>(); ArrayList<FileUri> sortedFiles = new ArrayList<FileUri>(); if (!newdirectory.equals(rootdir)) { String parentDirectory = new File(directory).getParent() + "/"; Uri uri = Uri.parse("file://" + parentDirectory); sortedDirs.add(new FileUri(uri, parentDirectory)); } try { File dir = new File(directory); File[] files = dir.listFiles(); if (files != null) { for (File file : files) { if (file == null) { continue; } String filename = file.getName(); if (file.isDirectory()) { Uri uri = Uri.parse("file://" + file.getAbsolutePath() + "/"); FileUri fileuri = new FileUri(uri, uri.getPath()); sortedDirs.add(fileuri); } else if (filename.endsWith(".mid") || filename.endsWith(".MID") || filename.endsWith(".midi") || filename.endsWith(".MIDI")) { Uri uri = Uri.parse("file://" + file.getAbsolutePath()); FileUri fileuri = new FileUri(uri, uri.getLastPathSegment()); sortedFiles.add(fileuri); } } } } catch (Exception e) { } if (sortedDirs.size() > 0) { Collections.sort(sortedDirs, sortedDirs.get(0)); } if (sortedFiles.size() > 0) { Collections.sort(sortedFiles, sortedFiles.get(0)); } filelist.addAll(sortedDirs); filelist.addAll(sortedFiles); adapter = new IconArrayAdapter<FileUri>(this, android.R.layout.simple_list_item_1, filelist); this.setListAdapter(adapter); }
public List<SMSBean> getThreads(int number) { Cursor cursor = null; ContentResolver contentResolver = mContext.getContentResolver(); List<SMSBean> list = new ArrayList<SMSBean>(); try { if (number > 0) { cursor = contentResolver.query( Uri.parse(CONTENT_URI_SMS_CONVERSATIONS), THREAD_COLUMNS, null, null, "thread_id desc limit " + number); } else { cursor = contentResolver.query( Uri.parse(CONTENT_URI_SMS_CONVERSATIONS), THREAD_COLUMNS, null, null, "date desc"); } if (cursor == null || cursor.getCount() == 0) return list; for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); SMSBean mmt = new SMSBean(cursor.getString(0), cursor.getString(1), cursor.getString(2), false); list.add(mmt); } return list; } catch (Exception e) { return list; } }
public void onClick(View v) { // Perform action on click try { Log.e(TAG, home.getString("location")); if (UIUtils.checkGoogleMap(HomeActivity.this)) { // Intent it = new Intent(Intent.ACTION_VIEW, // Uri.parse("geo:0,0?q=" + home.getString("location") // + "&hl=zh&z=15")); set_location(); String uri = "http://maps.google.com/maps?f=d&saddr=" + latitude + "," + longitude + "&daddr=" + home.getString("location") + "&hl=en"; Intent it = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); startActivity(it); } else { Intent it = new Intent( Intent.ACTION_VIEW, Uri.parse( "http://ditu.google.cn/maps?hl=zh&mrt=loc&q=" + home.getString("location"))); startActivity(it); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void setAsCurrent() { if (mUri == null) { return; } Cursor cur = mContext.getContentResolver().query(mUri, null, null, null, null); cur.moveToFirst(); int index = cur.getColumnIndex("_id"); String apnId = cur.getString(index); cur.close(); ContentValues values = new ContentValues(); values.put("apn_id", apnId); if (mSlot == -1) { mContext .getContentResolver() .update(Uri.parse("content://telephony/carriers/preferapn"), values, null, null); } else { int simNo = mSlot + 1; mContext .getContentResolver() .update( Uri.parse("content://telephony/carriers_sim" + simNo + "/preferapn"), values, null, null); } }
@Override public void openItem(int position) { if (position == 0) { Uri uri_to_go = null; if (parentLink == SLS) uri_to_go = Uri.parse(HomeAdapter.DEFAULT_LOC); else { // 0000-0000:folder%2Fsubfolder uri_to_go = getParent(uri); if (uri_to_go == null) uri_to_go = Uri.parse(HomeAdapter.DEFAULT_LOC); } String pos_to = null; String cur_path = getPath(uri, true); if (cur_path != null) pos_to = cur_path.substring(cur_path.lastIndexOf('/')); commander.Navigate(uri_to_go, null, pos_to); } else { Item item = items[position - 1]; if (item.dir) commander.Navigate((Uri) item.origin, null, null); else { Uri to_open; String full_name = getItemName(position, true); if (full_name != null && full_name.charAt(0) == '/') to_open = Uri.parse(Utils.escapePath(full_name)); else to_open = (Uri) item.origin; commander.Open(to_open, null); } } }