List of usage examples for android.net NetworkInfo getTypeName
@Deprecated
public String getTypeName()
From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java
private boolean isNetworkConnected() { NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null) { Log.d(TAG, "Network found, type = " + networkInfo.getTypeName()); return networkInfo.isConnected(); } else {/*from w w w .j a v a2s . com*/ Log.d(TAG, "No active network info"); return false; } }
From source file:org.openchaos.android.fooping.service.PingService.java
@Override protected void onHandleIntent(Intent intent) { String clientID = prefs.getString("ClientID", "unknown"); long ts = System.currentTimeMillis(); Log.d(tag, "onHandleIntent()"); // always send ping if (true) {// w ww.j a v a 2 s.c o m try { JSONObject json = new JSONObject(); json.put("client", clientID); json.put("type", "ping"); json.put("ts", ts); sendMessage(json); } catch (Exception e) { Log.e(tag, e.toString()); e.printStackTrace(); } } // http://developer.android.com/training/monitoring-device-state/battery-monitoring.html // http://developer.android.com/reference/android/os/BatteryManager.html if (prefs.getBoolean("UseBattery", false)) { try { JSONObject json = new JSONObject(); json.put("client", clientID); json.put("type", "battery"); json.put("ts", ts); Intent batteryStatus = registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); if (batteryStatus != null) { JSONObject bat_data = new JSONObject(); int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1); if (level >= 0 && scale > 0) { bat_data.put("pct", roundValue(((double) level / (double) scale) * 100, 2)); } else { Log.w(tag, "Battery level unknown"); bat_data.put("pct", -1); } bat_data.put("health", batteryStatus.getIntExtra(BatteryManager.EXTRA_HEALTH, -1)); bat_data.put("status", batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1)); bat_data.put("plug", batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1)); bat_data.put("volt", batteryStatus.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1)); bat_data.put("temp", batteryStatus.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1)); bat_data.put("tech", batteryStatus.getStringExtra(BatteryManager.EXTRA_TECHNOLOGY)); // bat_data.put("present", batteryStatus.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false)); json.put("battery", bat_data); } sendMessage(json); } catch (Exception e) { Log.e(tag, e.toString()); e.printStackTrace(); } } // http://developer.android.com/guide/topics/location/strategies.html // http://developer.android.com/reference/android/location/LocationManager.html if (prefs.getBoolean("UseGPS", false)) { try { JSONObject json = new JSONObject(); json.put("client", clientID); json.put("type", "loc_gps"); json.put("ts", ts); if (lm == null) { lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); } Location last_loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (last_loc != null) { JSONObject loc_data = new JSONObject(); loc_data.put("ts", last_loc.getTime()); loc_data.put("lat", last_loc.getLatitude()); loc_data.put("lon", last_loc.getLongitude()); if (last_loc.hasAltitude()) loc_data.put("alt", roundValue(last_loc.getAltitude(), 4)); if (last_loc.hasAccuracy()) loc_data.put("acc", roundValue(last_loc.getAccuracy(), 4)); if (last_loc.hasSpeed()) loc_data.put("speed", roundValue(last_loc.getSpeed(), 4)); if (last_loc.hasBearing()) loc_data.put("bearing", roundValue(last_loc.getBearing(), 4)); json.put("loc_gps", loc_data); } sendMessage(json); } catch (Exception e) { Log.e(tag, e.toString()); e.printStackTrace(); } } if (prefs.getBoolean("UseNetwork", false)) { try { JSONObject json = new JSONObject(); json.put("client", clientID); json.put("type", "loc_net"); json.put("ts", ts); if (lm == null) { lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); } Location last_loc = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (last_loc != null) { JSONObject loc_data = new JSONObject(); loc_data.put("ts", last_loc.getTime()); loc_data.put("lat", last_loc.getLatitude()); loc_data.put("lon", last_loc.getLongitude()); if (last_loc.hasAltitude()) loc_data.put("alt", roundValue(last_loc.getAltitude(), 4)); if (last_loc.hasAccuracy()) loc_data.put("acc", roundValue(last_loc.getAccuracy(), 4)); if (last_loc.hasSpeed()) loc_data.put("speed", roundValue(last_loc.getSpeed(), 4)); if (last_loc.hasBearing()) loc_data.put("bearing", roundValue(last_loc.getBearing(), 4)); json.put("loc_net", loc_data); } sendMessage(json); } catch (Exception e) { Log.e(tag, e.toString()); e.printStackTrace(); } } // http://developer.android.com/reference/android/net/wifi/WifiManager.html if (prefs.getBoolean("UseWIFI", false)) { try { JSONObject json = new JSONObject(); json.put("client", clientID); json.put("type", "wifi"); json.put("ts", ts); if (wm == null) { wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); } List<ScanResult> wifiScan = wm.getScanResults(); if (wifiScan != null) { JSONArray wifi_list = new JSONArray(); for (ScanResult wifi : wifiScan) { JSONObject wifi_data = new JSONObject(); wifi_data.put("BSSID", wifi.BSSID); wifi_data.put("SSID", wifi.SSID); wifi_data.put("freq", wifi.frequency); wifi_data.put("level", wifi.level); // wifi_data.put("cap", wifi.capabilities); // wifi_data.put("ts", wifi.timestamp); wifi_list.put(wifi_data); } json.put("wifi", wifi_list); } sendMessage(json); } catch (Exception e) { Log.e(tag, e.toString()); e.printStackTrace(); } } // TODO: cannot poll sensors. register receiver to cache sensor data // http://developer.android.com/guide/topics/sensors/sensors_overview.html // http://developer.android.com/reference/android/hardware/SensorManager.html if (prefs.getBoolean("UseSensors", false)) { try { JSONObject json = new JSONObject(); json.put("client", clientID); json.put("type", "sensors"); json.put("ts", ts); if (sm == null) { sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); } List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ALL); if (sensors != null) { JSONArray sensor_list = new JSONArray(); for (Sensor sensor : sensors) { JSONObject sensor_info = new JSONObject(); sensor_info.put("name", sensor.getName()); sensor_info.put("type", sensor.getType()); sensor_info.put("vendor", sensor.getVendor()); sensor_info.put("version", sensor.getVersion()); sensor_info.put("power", roundValue(sensor.getPower(), 4)); sensor_info.put("resolution", roundValue(sensor.getResolution(), 4)); sensor_info.put("range", roundValue(sensor.getMaximumRange(), 4)); sensor_list.put(sensor_info); } json.put("sensors", sensor_list); } sendMessage(json); } catch (Exception e) { Log.e(tag, e.toString()); e.printStackTrace(); } } // http://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html // http://developer.android.com/reference/android/net/ConnectivityManager.html if (prefs.getBoolean("UseConn", false)) { try { JSONObject json = new JSONObject(); json.put("client", clientID); json.put("type", "conn"); json.put("ts", ts); if (cm == null) { cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); } // TODO: add active/all preferences below UseConn if (prefs.getBoolean("UseConnActive", true)) { NetworkInfo net = cm.getActiveNetworkInfo(); if (net != null) { JSONObject net_data = new JSONObject(); net_data.put("type", net.getTypeName()); net_data.put("subtype", net.getSubtypeName()); net_data.put("connected", net.isConnected()); net_data.put("available", net.isAvailable()); net_data.put("roaming", net.isRoaming()); net_data.put("failover", net.isFailover()); if (net.getReason() != null) net_data.put("reason", net.getReason()); if (net.getExtraInfo() != null) net_data.put("extra", net.getExtraInfo()); json.put("conn_active", net_data); } } if (prefs.getBoolean("UseConnAll", false)) { NetworkInfo[] nets = cm.getAllNetworkInfo(); if (nets != null) { JSONArray net_list = new JSONArray(); for (NetworkInfo net : nets) { JSONObject net_data = new JSONObject(); net_data.put("type", net.getTypeName()); net_data.put("subtype", net.getSubtypeName()); net_data.put("connected", net.isConnected()); net_data.put("available", net.isAvailable()); net_data.put("roaming", net.isRoaming()); net_data.put("failover", net.isFailover()); if (net.getReason() != null) net_data.put("reason", net.getReason()); if (net.getExtraInfo() != null) net_data.put("extra", net.getExtraInfo()); net_list.put(net_data); } json.put("conn_all", net_list); } } sendMessage(json); } catch (Exception e) { Log.e(tag, e.toString()); e.printStackTrace(); } } if (!PingServiceReceiver.completeWakefulIntent(intent)) { Log.w(tag, "completeWakefulIntent() failed. no active wake lock?"); } }
From source file:org.simlar.SimlarService.java
void checkNetworkConnectivityAndRefreshRegisters() { final NetworkInfo ni = ((ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();/*w w w .j a v a 2 s . c o m*/ if (ni == null) { Log.e(LOGTAG, "no NetworkInfo found"); return; } Log.i(LOGTAG, "NetworkInfo " + ni.getTypeName() + " " + ni.getState()); if (ni.isConnected()) { mLinphoneThread.refreshRegisters(); } }
From source file:com.cyanogenmod.settings.device.LtoDownloadService.java
private boolean shouldDownload(boolean forceDownload) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); boolean hasConnection = false; if (info == null || !info.isConnected()) { if (ALOGV) Log.v(TAG, "No network connection is available for LTO download"); } else if (forceDownload) { if (ALOGV) Log.v(TAG, "Download was forced, overriding network type check"); hasConnection = true;//from w ww.j a v a2 s . c om } else { boolean wifiOnly = prefs.getBoolean(KEY_WIFI_ONLY, WIFI_ONLY_DEFAULT); if (wifiOnly && info.getType() != ConnectivityManager.TYPE_WIFI) { if (ALOGV) { Log.v(TAG, "Active network is of type " + info.getTypeName() + ", but Wifi only was selected"); } } else { hasConnection = true; } } if (!hasConnection) { return false; } if (forceDownload) { return true; } if (!prefs.getBoolean(KEY_ENABLED, false)) { return false; } long now = System.currentTimeMillis(); long lastDownload = LtoDownloadUtils.getLastDownload(this); long due = lastDownload + LtoDownloadUtils.getDownloadInterval(this); if (ALOGV) { Log.v(TAG, "Now " + now + " due " + due + "(" + new Date(due) + ")"); } if (lastDownload != 0 && now < due) { if (ALOGV) Log.v(TAG, "LTO download is not due yet"); return false; } return true; }
From source file:usbong.android.utils.UsbongUtils.java
public static boolean hasNetworkConnection(Context context) { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; }// ww w . j a v a2 s .c om return haveConnectedWifi || haveConnectedMobile; }
From source file:org.openhab.habdroid.ui.OpenHABStartupActivity.java
private void initPage() { if (!tryManualUrl()) { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetworkInfo != null) { Log.i(TAG, "Network is connected"); if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI || activeNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) { Log.i(TAG, "Network is WiFi or Ethernet"); AsyncServiceResolver serviceResolver = new AsyncServiceResolver(this, openHABServiceType); if (!this.isFinishing()) progressDialog = ProgressDialog.show(OpenHABStartupActivity.this, "", "Discovering openHAB. Please wait...", true); serviceResolver.start(); } else if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { Log.i(TAG, "Network is Mobile (" + activeNetworkInfo.getSubtypeName() + ")"); onAlternativeUrl();//from w ww .j a v a 2 s .c om } else { Log.i(TAG, "Network type (" + activeNetworkInfo.getTypeName() + ") is unsupported"); } } else { Log.i(TAG, "Network is not available"); Toast.makeText(getApplicationContext(), "@string/error_network_not_available", Toast.LENGTH_LONG) .show(); } } }
From source file:fr.inria.ucn.collectors.NetworkStateCollector.java
/** * /* w w w .ja v a 2s.c o m*/ * @param c * @param ts * @param change */ @SuppressWarnings("deprecation") @SuppressLint({ "DefaultLocale", "NewApi" }) public void run(Context c, long ts, boolean change) { try { // current active interface (wifi or mobile) and config ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); JSONObject data = new JSONObject(); data.put("on_network_state_change", change); // this collection run was triggered by network change data.put("is_connected", (ni != null && ni.isConnectedOrConnecting())); data.put("is_roaming", tm.isNetworkRoaming()); // airplane mode ? if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.JELLY_BEAN) { data.put("is_airplane_mode", (Settings.System.getInt(c.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0)); } else { data.put("is_airplane_mode", (Settings.Global.getInt(c.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0)); } if (ni != null) { JSONObject active = new JSONObject(); active.put("type", ni.getType()); active.put("subtype", ni.getSubtype()); active.put("type_name", ni.getTypeName()); active.put("subtype_name", ni.getSubtypeName()); active.put("state", ni.getState().toString()); active.put("detailed_state", ni.getDetailedState().toString()); active.put("is_wifi", (ni.getType() == ConnectivityManager.TYPE_WIFI)); data.put("active_network", active); if (ni.getType() == ConnectivityManager.TYPE_WIFI) { data.put("wifi_network", getWifi(c)); } } // mobile network details data.put("mobile_network", getMobile(tm)); // kernel network statistics data.put("netstat", getNetstat()); // interfaces config Map<String, JSONObject> stats = networkStats(); data.put("ifconfig", getIfconfig(stats)); // double check interfaces data.put("ip_addr_show", getIpAddr(stats)); Helpers.sendResultObj(c, "network_state", ts, data); } catch (JSONException jex) { Log.w(Constants.LOGTAG, "failed to create json object", jex); } }
From source file:com.fvd.nimbus.BrowseActivity.java
public boolean hasInternetConnection() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) { return false; }/*from www .j a v a2 s . c om*/ NetworkInfo[] netInfo = cm.getAllNetworkInfo(); if (netInfo == null) { return false; } for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) { //Log.d(this.toString(), "test: wifi conncetion found"); return true; } if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) { //Log.d(this.toString(), "test: mobile connection found"); return true; } } return false; }
From source file:com.BeatYourRecord.SubmitActivity.java
@Override public void onCreate(Bundle savedInstanceState) { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; }/*from w w w . ja va 2 s . c o m*/ if (haveConnectedWifi == false) { showDialog(11); } super.onCreate(savedInstanceState); // SharedPreferences pref = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref.edit(); //auth = pref.getString("BYR_session", null); /*SharedPreferences pref6 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor7 = pref6.edit(); //this.setContentView(R.layout.submit); String logoutme = pref6.getString("log", null); //log.v("log",logoutme); */ SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor1 = pref1.edit(); tourid = pref1.getString("id", null); logout = pref1.getString("log", null); filepath = pref1.getString("filepath", null); //log.v("id",tourid); //log.v("log",logout); Log.v("reached here first", "reached here first"); File f = new File("/data/data/com.BeatYourRecord/shared_prefs/Tester15.xml"); if (f.exists() && logout.equals("yes") == false) { //log.v("yyy","yyy"); SharedPreferences pref = SubmitActivity.this.getSharedPreferences("Tester15", 0); // 0 - for private mode Editor editor = pref.edit(); this.setContentView(R.layout.submit); auth = pref.getString("BYR_session", null); } else { //log.v("yyy","yyy1"); this.setContentView(R.layout.submit1); showDialog(10); } // String checksession = pref.getString("BYR_session", null); // //log.v("checksession", checksession); ////log.v("Authhere",auth); this.authorizer = new ClientLoginAuthorizer.ClientLoginAuthorizerFactory().getAuthorizer(this, ClientLoginAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE); dbHelper = new DbHelper(this); dbHelper = dbHelper.open(); Intent intent = this.getIntent(); this.videoUri = intent.getData(); SharedPreferences pref1223 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor1223 = pref1223.edit(); filepath = pref1223.getString("filepath", null); // this.videoUri = // Uri path = Uri.parse(filepath); //File f1 = new File(filepath); //Uri imageUri = Uri.fromFile(f1); //this.videoUri = imageUri; //this.videoUri = path; Log.v("Reached here second", "Reached here secord"); //this.videoUri= Uri.fromFile(new File("/sdcard/Movies/com.BeatYourRecord/BYR_tournName_dateTim_20130724181901222.mp4")); //log.v("haha","haha"); MediaScannerConnectionClient mediaScannerClient = new MediaScannerConnectionClient() { private MediaScannerConnection msc = null; { msc = new MediaScannerConnection(getApplicationContext(), this); msc.connect(); } public void onMediaScannerConnected() { msc.scanFile(filepath, null); } public void onScanCompleted(String path, Uri uri) { //This is where you get your content uri Log.d("test3", uri.toString()); needed = uri; // videoUri=needed; msc.disconnect(); } }; String videoPath = ""; try { videoPath = getFilePathFromUri(this.videoUri); filepath1 = videoPath; Log.v("videoPath", videoPath); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } File videoFile = new File(videoPath); this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN); this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID); this.domainHeader = (TextView) this.findViewById(R.id.domainHeader); domainHeader.setText(SettingActivity.getYtdDomains(this).get(this.ytdDomain)); this.preferences = this.getSharedPreferences(MainActivity.SHARED_PREF_NAME, Activity.MODE_PRIVATE); this.youTubeName = preferences.getString(DbHelper.YT_ACCOUNT, null); final Button submitButton = (Button) findViewById(R.id.submitButton); submitButton.setEnabled(false); submitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDialog(DIALOG_LEGAL); } }); addusertotournament(); Button cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref1.edit(); //editor.putString("filepath", permfilepath); //editor.commit(); Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class); // intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com"); //intent.setData(Uri.fromFile(file)); startActivity(intent); finish(); // setResult(RESULT_CANCELED); //finish(); } }); Button forgotButton = (Button) findViewById(R.id.forgotButton); forgotButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref1.edit(); //editor.putString("filepath", permfilepath); //editor.commit(); SharedPreferences pref155 = getApplicationContext().getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor155 = pref155.edit(); editor155.putString("filepath", filepath1); editor155.commit(); Log.v("fielpathss", filepath1); Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class); // intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com"); //intent.setData(Uri.fromFile(file)); startActivity(intent); // finish(); // setResult(RESULT_CANCELED); //finish(); } }); EditText titleEdit = (EditText) findViewById(R.id.submitTitle); titleEdit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { enableSubmitIfReady(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription); descriptionEdit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { enableSubmitIfReady(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); Cursor cursor = this.managedQuery(this.videoUri, null, null, null, null); if (cursor.getCount() == 0) { Log.d(LOG_TAG, "not a valid video uri"); Toast.makeText(SubmitActivity.this, "not a valid video uri", Toast.LENGTH_LONG).show(); } else { getVideoLocation(); if (cursor.moveToFirst()) { long id = cursor.getLong(cursor.getColumnIndex(Video.VideoColumns._ID)); this.dateTaken = new Date(cursor.getLong(cursor.getColumnIndex(Video.VideoColumns.DATE_TAKEN))); Log.v("here", "here12"); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm aaa"); Configuration userConfig = new Configuration(); Settings.System.getConfiguration(getContentResolver(), userConfig); /* Calendar cal = Calendar.getInstance(userConfig.locale); TimeZone tz = cal.getTimeZone();*/ Log.v("here", "here13"); // dateFormat.setTimeZone(tz); TextView dateTakenView = (TextView) findViewById(R.id.dateCaptured); dateTakenView.setText("Date captured: " + dateFormat.format(dateTaken)); ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail); ContentResolver crThumb = getContentResolver(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 1; Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options); thumbnail.setImageBitmap(curThumb); } } }