Tag Archives: code

5,938 views

Permission settings of Android application example

In your project AndroidManifest.xml you can set permission of Android application example source code. For example if you want allow your application connection to INTERNET you have to permit this in AndroidManifest.xml. WebViev show error: Website Not Available you have … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on Permission settings of Android application example
10,792 views

Get package name Context-getPackageName Android example

If you often copy your Android project to another you have to using function for obtaining varied information about package. This code show how get package name in Android application as string: Context context = getContext(); // this.getContext(); getApplicationContext(); etc. … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on Get package name Context-getPackageName Android example
8,966 views

Copy sqlite database from apk package to device folder Android example

Put your sglite database to Android Eclipse project folder named Assets. On device will copy database file to application folder as this example:   public void createDatabase(Context myContext) throws IOException { String sPackName = myContext.getPackageName(); InputStream assetsDB = myContext.getAssets().open("myDatabase"); OutputStream … Continue reading

Posted in SQLite database | Tagged , , , , , , | Comments Off on Copy sqlite database from apk package to device folder Android example
5,958 views

Hide keyboard Android example

Use this code for example in some method or function // public Object getSystemService (String name) // Return the handle to a system-level service by name. // The class of the returned object varies by the requested name. InputMethodManager inputMethodManager … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on Hide keyboard Android example
10,165 views

TTS text to speech Android example

Android development example source code // import import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; // you have to add implementation public class Main extends Activity implements TextToSpeech.OnInitListener { private int _langTTSavailable = -1; // set up in onInit method // declaration private TextToSpeech … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on TTS text to speech Android example
6,986 views

Number convert int to string Java Android example code

Convert number int to string Android Java example source code. int n = 0;   try { n = Integer.parseInt("21")); } catch(NumberFormatException e) { System.out.println("Could not parse " + e); } // int to string String s = String.valueOf(24);

Posted in Android Examples Code, Array,List,Collections | Tagged , , , | Comments Off on Number convert int to string Java Android example code
2,622 views

Screen Android Landscape Portrait programmatically

Screen Android example source code for developers. Get orientation of screen. public int getScreenOrientation() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { return 1; // Portrait Mode   }else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { return 2; // Landscape mode } return 0; … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on Screen Android Landscape Portrait programmatically
7,151 views

Display screen size resolution density dimension Android

Get display, screen resolution – dimension Android phone development example source code. Display display = getWindowManager().getDefaultDisplay(); int nWidth = display.getWidth(); int nHeight = display.getHeight();   DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); //get density per inch for example: 120 , 160 … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on Display screen size resolution density dimension Android
10,040 views

Show keyboard in WebView Android example

Show keyboard if WebView input have focus Android apps development example source code. WebView webview;   //in onCreate   webview = (WebView) findViewById(R.id.idWebviewPda); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl("http://android.okhelp.cz");   webview.requestFocus(View.FOCUS_DOWN); webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , , , | Comments Off on Show keyboard in WebView Android example
4,130 views

Show keyboard

Show keyboard Android phone apps development example source code. // ActivityClass.java InputMethodManager showSoftInput; Button hBtnKeyboardShow ; //onCreate showSoftInput = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE);   hBtnKeyboardShow = (Button)findViewById(R.id.btnKeyboardShow); hBtnKeyboardShow.setOnClickListener(myButtonListener); // END onCreate   //button listener private OnClickListener myButtonListener = new OnClickListener() { public void … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on Show keyboard