getting the screen density programmatically in android?

You can get info on the display from the DisplayMetrics struct: DisplayMetrics metrics = getResources().getDisplayMetrics(); Though Android doesn’t use a direct pixel mapping, it uses a handful of quantized Density Independent Pixel values then scales to the actual screen size. So the metrics.densityDpi property will be one of the DENSITY_xxx constants (120, 160, 213, 240, … Read more

IllegalStateException: Can not perform this action after onSaveInstanceState with ViewPager

Please check my answer here. Basically I just had to : @Override protected void onSaveInstanceState(Bundle outState) { //No call for super(). Bug on API Level > 11. } Don’t make the call to super() on the saveInstanceState method. This was messing things up… This is a known bug in the support package. If you need … Read more

How to load an ImageView by URL in Android? [closed]

From Android developer: // show The Image in a ImageView new DownloadImageTask((ImageView) findViewById(R.id.imageView1)) .execute(“http://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png”); public void onClick(View v) { startActivity(new Intent(this, IndexActivity.class)); finish(); } private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { ImageView bmImage; public DownloadImageTask(ImageView bmImage) { this.bmImage = bmImage; } protected Bitmap doInBackground(String… urls) { String urldisplay = urls[0]; Bitmap mIcon11 = null; … Read more

Allow multi-line in EditText view in Android?

By default all the EditText widgets in Android are multi-lined. Here is some sample code: <EditText android:inputType=”textMultiLine” <!– Multiline input –> android:lines=”8″ <!– Total Lines prior display –> android:minLines=”6″ <!– Minimum lines –> android:gravity=”top|start” <!– Cursor Position –> android:maxLines=”10″ <!– Maximum Lines –> android:layout_height=”wrap_content” <!– Height determined by content –> android:layout_width=”match_parent” <!– Fill entire width … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)