Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Android Studio Browse Files Data Device Emulator


AD MOB

1.) Open DDMS via Menu Tools > Android > Android Device Monitor
2.) Select Device
3.) In DDMS click Menu Window > Show View > File Exlporer
4.) Device > Storage folder
5.) Emulator > data > data folder

397LW NO topic_id




AD

Další témata ....(Topics)


97

How going life cycle if screen orientation changed Android example | how-going-life-cycle-if-screen-orientation-changed-android-example


onSaveInstanceState, onRestoreInstanceState life cycle if screen orientation changed from log file.

// starts activity
15:27:12.801: INFO/onCreate(1828): onCreate()
15:27:12.811: INFO/onStart(1828): onStart()
15:27:12.821: INFO/onResume(1828): onResume()
// activity is running 

15:27:33.651: DEBUG/dalvikvm(307): GC_EXPLICIT freed 186K, 53% 
free 2770K/5831K, external 981K/1038K, paused 99ms

// change emulator state Ctrl+F11 landscape, portrait
15:27:40.427: INFO/ActivityManager(74): Config changed: 
{ scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=18 uiMode=17 seq=64}

// saved all variable values if need
15:27:40.581: INFO/onSaveInstanceState(1828): onSaveInstanceState()

15:27:40.602: INFO/onPause(1828): onPause()
15:27:40.612: INFO/onStop(1828): onStop()
15:27:40.631: INFO/onDestroy(1828): onDestroy()

// activity goes back to onCreate !!!!!!!!!
15:27:40.692: INFO/onCreate(1828): onCreate()
15:27:40.701: INFO/onStart(1828): onStart()

// restore all saved values of variables 
15:27:40.711: INFO/onRestoreInstanceState(1828): onRestoreInstanceState()
// you can using saved values by onSaveInstanceState() in onResume
15:27:40.721: INFO/onResume(1828): onResume()




Diagram of life cycle onSaveInstanceState, onRestoreInstanceState

[caption id="attachment_1169" align="alignleft" width="229" caption="Life cycle onRestoreInstanceState"]life_cycle_onRestoreInstanceState[/caption]
300

Do not hardcode /data/ use Context.getFilesDir().getPath() | do-not-hardcode-data-use-context-getfilesdir-getpath



// warning
private static String DB_PATH =  "/data/data/cz.okhelp.german_czech_phrases/databases/";

// OK
   public DataBaseHelper(Context context) {	 
    	super(context, DB_NAME, null, 1);
        this.myContext = context;
        // OK
         DB_PATH = context.getFilesDir().getParentFile().getPath()
              + "/databases/";
    }
185

Get the color of a specific pixel Java Android example | get-the-color-of-a-specific-pixel-java-android-example



             ImputStream      is = this.getResources().openRawResource(R.drawable.colors);
             Bitmap    mBitmap2 = BitmapFactory.decodeStream(is);
        
         int  w = mBitmap2.getWidth();
         int  h = mBitmap2.getHeight();
//  int x , y have to be smaller as w , h 
         int _color =  mBitmap2.getPixel(x, y);

231

Date getDate is deprecated Java Android | date-getdate-is-deprecated-java-android


Date getDate is deprecated Java Android example code:


long dayInMili = 100000000;

GregorianCalendar calToDay = new GregorianCalendar();
int nD = calToDay.get((Calendar.MILLISECOND)); // +dayInMili;
System.out.println(nD);

long lTime = calToDay.getTimeInMillis();
System.out.println(lTime);

Date dtA = new Date(lTime); // today
///@SuppressWarnings("deprecation")
int nD1 = dtA.getDate(); // DEPRECATED Day Of Month 1 - 31
System.out.println(nD1+" nD1");

GregorianCalendar cal = new GregorianCalendar();
int nD2 = calToDay.get(Calendar.DATE); // Day Of Month
System.out.println(nD2+" nD2");

cal.setTimeInMillis(lTime+dayInMili);// setTime(dtA);
int nD3 = cal.get(Calendar.DATE); // Day Of Month + 1 day
System.out.println(nD3+" nD3");


223

Disable enable internet connection in Android Emulator | disable-enable-internet-connection-in-android-emulator


If you try function for checking internet connection you can disable internet on the emulator:
Settings - Wireless and networks - Mobile networks - Data enabled (checked - unchecked )


 public boolean isNetworkAvailable() {
        ConnectivityManager cm = (ConnectivityManager) 
          getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected()) {
            return true;
        }
        return false;
    }     







Editace: 2017-01-28 20:49:16
Počet článků v kategorii: 397
Url:android-studio-browse-data-device-emulator

AD
11 Share
Share
Tweet