239 views

Get Screen Size Pixels per Inch Android example

The exact physical pixels per inch of the screen
Get size of pixel
Get DPI
Get count of pixels per inch

        float mXDpi;
        float mYDpi;
           DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            mXDpi = metrics.xdpi; // The exact physical pixels per inch of the screen in the X dimension. 
            mYDpi = metrics.ydpi;
          float  mMetersToPixelsX = mXDpi / 0.0254f; // 1 inch == 0.0254 metre
          float  mMetersToPixelsY = mYDpi / 0.0254f;
Posted in Android Development Tutorial | Tagged , | Leave a comment
345 views

Invalid proguard configuration file path Android Eclipse Error

Invalid proguard configuration file path
C:\documents\my_android_projects\my_project\proguard.cfg does not exist or is not a regular file

Solution:
Check if exist file proguard.cfg in your project on the path C:\docum………
If not exist, copy a file proguard.cfg from other project or create file proguard.cfg and insert
this source code to file and save this file.

 
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
 
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
 
-keepclasseswithmembernames class * {
    native <methods>;
}
 
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}
 
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}
 
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}
 
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
 
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

From more details see:

http://developer.android.com/guide/developing/tools/proguard.html

Posted in Android Development Tutorial | Tagged , | Leave a comment
198 views

Wiki Browser home page

A web browser for Wikipedia.
The browser for OS Android 2.1 and higher.
Features:
-back button
-history
-forward button
-save the page as favorite
-open favorite
-page up
-page down
-online dictionary for 65 languages

Download

wiki browser

Posted in Android Software Download | Tagged | Leave a comment
279 views

Error android.widget.LinearLayout.measureHorizontal LinearLayout.java

Code with error:

ImageView imgV = (ImageView)findViewById(R.id.myView);
        imgV.setLayoutParams(new ViewGroup.LayoutParams(
        		ViewGroup.LayoutParams.WRAP_CONTENT,
        		0));

If you get error try this code:

        ViewGroup.LayoutParams layoutParams = imgV
				.getLayoutParams();
		layoutParams.height = 0;
		imgV.setLayoutParams(layoutParams);

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:659)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:311)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
at android.view.View.measure(View.java:8313)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8313)

Posted in Android Development Tutorial | Tagged , , | Leave a comment
1,140 views

NoClassDefFoundError: com.google.ads.AdView ADT 17

Eclipse update ADT 17 Android Emulator error: E/AndroidRuntime(370): java.lang.NoClassDefFoundError: com.google.ads.AdView

Solution:
-right click on the project in project tree and select Project properties
-select Java Build Path
-select TAB Order and Export
-check GoogleAdMobAdsSdk-4.0.4.jar (or your version SDK)
-press OK
-clean project by menu Project -> Clean
-rebuild project (Project – Build Automatically)

How add GoogleAdMobAdsSdk….jar to project:
-right click on the project in project tree and select Project properties
-select Java Build Path
-select TAB Libraries
-press the button Add External JARs…
-select your version GoogleAdMobAdsSdkXXX.jar what you can using
-OK
-OK
-clean project
-rebuild project

menu-item-project-properties-eclipse
order-and-export-eclipse dialogue
eclipse-add-jar-library-to-project

Posted in Android Development Tutorial | Tagged | Leave a comment
211 views

Resource is out of sync with the file system Eclipse error

Could not open the editor: Resource is out of sync with the file system: ‘/my_project/project.properties’.

If you get this message close file, select file in the folder tree and press F5 on file in the Eclipse folder tree. Reopen this file.

Posted in Android Development Tutorial | Tagged | Leave a comment
283 views

Geometry Calculator Volume Surface Area Mass

Download free calculator to calculate volume, surface, area and mass of the Sphere, Circle, Cylinder, Cone, Cube and off-line geometry formulas.

Download Geometry Calculator

Posted in Android Software Download | Tagged , | Leave a comment
282 views

Set Drawable programmatically Android example

// start_dark.png is stored in path	/package_name/res/drawable/start_dark.png
Drawable dw = getApplicationContext().getResources().getDrawable(R.drawable.start_dark);
Button hButtonStart = (Button)findViewById(R.id.buttonStart);
hButtonStart.setCompoundDrawablesWithIntrinsicBounds(dw, null, null, null);
Posted in Android Development Tutorial | Tagged , | Leave a comment
262 views

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);
Posted in Android Development Tutorial | Tagged , , , | Leave a comment
260 views

Transparent Background Android example

android:background=”@android:color/transparent”

<LinearLayout
    android:baselineAligned="false"
    android:background="@android:color/transparent"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
   >
<LinearLayout>
////////////////////////////
LinearLayout  mLinearLayout1 = (LinearLayout)findViewById(R.id.linearLayout1);
mLinearLayout1.setBackgroundColor(Color.TRANSPARENT);
Posted in Android Development Tutorial | Tagged | Leave a comment
260 views