Android notes

Toast.makeText(getApplicationContext(), "no gps or network is on", Toast.LENGTH_LONG).show();

//SD card ထဲက database file ကို တန္းဖတ္ၿပီး သံုးဖို႔အတြက္
File dbfile = new File("/sdcard/Your_db_File.db" );
SQLiteDatabase  db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);

//app ကို ေထာင္လိုက္ပဲ အျမဲေပၚေစဖို႔ နည္းလမ္းမ်ား
Just you have to define below property to your activity inside manifest file, It will restrict your activity to portrait.
android:screenOrientation="portrait"
Example:
        <activity
            android:name="com.example.demo_spinner.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
[...] you should also explicitly declare that your application requires either portrait or landscape orientation with the element. For example,<uses-feature android:name="android.hardware.screen.portrait" />.
if(isTablet)
{
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);      
}else
{
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

This will force your app to be portrait on both phones and tablets.
You can have the app forced in the device's "preferred" orientation by using
android:screenOrientation="nosensor"
This will lead to forcing your app to portrait on most phones phones and landscape on tablets. There are many phones with keypads which were designed for landscape mode. Forcing your app to portrait can make it almost unusable on such devices. Android is recently migrating to other types of devices as well. It is best to just let the device choose the preferred orientation.
<activity android:name=".yourActivity"
          android:screenOrientation="portrait" ... />
add to main activity and add
android:configChanges="keyboardHidden"
to keep your program from changing mode when keyboard is called.

Comments