Force Screen On - dont use WakeLock - use getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) - Android sample
FLAG_KEEP_SCREEN_ON saving energy. Protects the battery if a user closing applications using the Return button on device. The device will returned to user screen mode settings.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
//..........
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
396LW NO topic_id
AD
Další témata ....(Topics)
How to resize an image in ImageView Android source code.
Resize imageview layout and image will resize too:
Resize imageview layout and image will resize too:
public void resizeImageView(int width, int height) {
final ImageView picture1 = (ImageView)findViewById(R.id.imageView1);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height);
picture1.setLayoutParams(layoutParams);
}
FrameLayou, fragment have to unique id android:id="@+id/your_id_unique"
<FrameLayout xmlns:android="//schemas.android.com/apk/res/android"
xmlns:tools="//schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/your_id_unique"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="cz.okhelp.notepad.AddNoteFragment"
tools:layout="@layout/add_note" />
</FrameLayout>
private int _nVersionCode = 0;
private boolean _bNewVersion = false;
// onCreate
_nVersionCode = this.getPackageManager()
.getPackageInfo(this.getPackageName(), 0).versionCode;
Log.d(String.valueOf(_nVersionCode), "versionCode");
// onStart loadPreferences
public void loadPreferences() {
//SharedPreferences settings = getSharedPreferences(F.PREFERENCES_NAME, 0);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
int nOldVersionCode = settings.getInt("_nVersionCode", 0);// old vesion
if(_nVersionCode > nOldVersionCode)
_bNewVersion = true;
}
// onDestroy savePreferences
public void savePreferences() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("_nVersionCode", _nVersionCode); // save current version code
editor.commit();
}
Solution:
public void alertMy(String sTitle, String sMessage){
AlertDialog.Builder builder = new AlertDialog.Builder(Test.this); // activity
builder.setTitle(sTitle)
.setMessage(sMessage)
.setCancelable(false)
.setNegativeButton("Close",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
Brand | Samsung |
Model (codename) | Galaxy Mini (S5570) |
Price (cena, včetně DPH) | 3500 / 06.2012 |
Display size in Inch (v palcích) | 3.14 |
Display-resolution | 240x320 |
Dotek-typ | kapacitní |
CPU typ | MSM7227 |
CPU MHz | 600 |
CPU core | |
L2 cache | yes |
RAM | 256 |
ROM | 512 |
GPU | Adreno 200 |
NenaMark2 Benchmark | |
GPU-GLBenchmark | |
Baterie mAh | 1200 |
Foto MPx | 3 |
Autofocus | no |
Video | QVGA (320 x 240) při 15 frames/s |
Official Android ICS | Android Froyo 2.2 |
CyanogenMod support | yes |
Dotek-prstů-max | Dual-touch (two fingers) |
Display-ppi | 127 |
Display-retina | 39% |
Networks | GSM&EDGE (850 / 900 / 1.800 / 1.900 MHz) 3G (900 / 2.100 MHz) |
Connectivity | Bluetooth V2.1 , USB V2.0 , USB mass storage , SyncML(DM) , WIFI , AGPS, 3.5 mm jack |
Note |
Samsung S5570 Galaxy Mini - image
Editace: 2011-11-07 20:43:56
Počet článků v kategorii: 396
Url:force-screen-on-dont-use-wakelock-use-getwindow-addflagswindowmanager-layoutparams-flag_keep_screen_on-android-sample