187 views

Eclipse update failed folder in use

Failed to rename directory ….
If using for update Android SDK manager,
try close Eclipse if is open.
Or change security settings of the folder which have problem.
Or disable antivirus for a moment.

Posted in Bugs, warnings, errors | Tagged , | Comments Off
234 views

View overrides onTouchEvent but not performClick

public class Panel extends SurfaceView implements SurfaceHolder.Callback {
//............... code
//............... some code
   /**
     * Process the MotionEvent.
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
 
        synchronized (getHolder()) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
            	performClick();
             } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            	if(_currentGraphic==null)return true;
 
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
            }
            return true;
        }
    }
/////////////////////////////
 @Override
 public boolean performClick() {
  // Calls the super implementation, which generates an AccessibilityEvent
        // and calls the onClick() listener on the view, if any
        super.performClick();
 
        // Handle the action for the custom click here
 
        return true;
 }
 
}
Posted in Android Examples Code, Bugs, warnings, errors | Tagged , , , | Comments Off
211 views

External Storage read write file

AndroidManifest.xml

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

MyActivity.java

	/* Checks if external storage is available for read and write */
	public boolean isExternalStorageWritable() {
	    String state = Environment.getExternalStorageState();
	    if (Environment.MEDIA_MOUNTED.equals(state)) {
	        return true;
	    }
	    return false;
	}	
 
 
 
   private String readFileOnExternalSD(String fileName){
    	File sdcard = Environment.getExternalStorageDirectory();
 
    	//Get the text file
    	File file = new File(sdcard.getAbsolutePath() + "/myfolder",fileName);
 
    	//Read text from file
    	StringBuilder text = new StringBuilder();
 
    	try {
    	    BufferedReader br = new BufferedReader(new FileReader(file));
    	    String line;
 
    	    while ((line = br.readLine()) != null) {
    	        text.append(line);
    	        text.append('\n');
    	    }
    	    br.close();
    	}
    	catch (IOException e) {
    	    // error handling here
    	}
        return text.toString();
    }
 
 
   private void writeToSDcardFile(String fileName, String sSomeText) {
        File sdcard = android.os.Environment.getExternalStorageDirectory();
        File dir = new File(sdcard.getAbsolutePath() + "/myfolder");
        dir.mkdirs();
        File file = new File(dir, fileName);// for example "myData.txt"
        try {
            FileOutputStream f = new FileOutputStream(file);
            PrintWriter pw = new PrintWriter(f);
            pw.println(sSomeText +"Hello world!");
            pw.println("Other text");
            pw.flush();
            pw.close();
            f.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
Posted in Android Examples Code | Tagged | Comments Off
306 views

Installation error: INSTALL_FAILED_CONTAINER_ERROR

1.) Try delete some apps from Android emulator (can from Eclipse DDMS perspective
– File Explorer tab – data/apps folder path )
2.) Try resize emulator internal storage or SD card storage to hight size
3.)Try add to AndroidManifest.xml android:installLocation=”preferExternal”

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myweb.mypackage"
    android:installLocation="preferExternal"

4.) Try resize particion from Eclipse
Preferences,
select Android- Launch
Add “-partition-size 1024″ into “Default emulator option” field.
Click “Apply” and use your emulator as usual

Posted in Bugs, warnings, errors, Eclipse | Tagged | Comments Off
353 views

layout id cannot be resolved or is not a field

1.) check your xml files in res/layout folder if contain errors or warnings, repair this
2.) try comment import R in Activity file
// import com.mysite.packagename.R;
3.) every clean and rebuild project

Posted in Bugs, warnings, errors, Eclipse | Tagged , | Comments Off
318 views

Set theme of AdActivity to @android:style/Theme.Translucent

AndroidManifest.xml

<activity android:name="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
              android:theme="@android:style/Theme.Translucent" />
Posted in Android Examples Code, Bugs, warnings, errors, Eclipse | Tagged , , | Comments Off
474 views

Admob ad not visible on Android Emulator

Try this solution:

AdView adView = new AdView(getApplicationContext());//in menu inflater getActivity()
adView.setAdUnitId("ca-app-pub-87***yourNumber");
adView.setAdSize(AdSize.BANNER); 					
LinearLayout linLay = (LinearLayout)findViewById(R.id.idReklamaLayout);
// Add the adView to it
linLay.addView(adView);
// Initiate a generic request to load it with an ad
if(Build.MANUFACTURER.equals("unknown")) {
// Emulator
AdRequest.Builder.addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB"); // to get test ads on this device.
AdRequest adRequest = new AdRequest.Builder()
 .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
 .addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB")  // Emulator id you will get in the LogCat verbose
 .build();
 
adView.loadAd(adRequest);
	  			/* */
}else {
 // Not Emulator
// Initiate a generic request to load it with an ad
AdRequest adRequest = new AdRequest.Builder().build();   
adView.loadAd(adRequest);/**/
}
Posted in Android Examples Code, Bugs, warnings, errors, Eclipse | Tagged , , | Comments Off
1,517 views

Emulator error: This AVD’s configuration is missing a kernel file

Android Studio
- open AVD manager
- press Create Virtual Device
- select one
- Next
- download system

Posted in Android Studio, Bugs, warnings, errors | Comments Off
507 views

Warning: com.google.android.gms.common.SupportErrorDialogFragment: can’t find referenced method

Try add to your project, next project in workspace appcompat_v7

Posted in Bugs, warnings, errors | Tagged , | Comments Off
370 views

proguard.ParseException: Expecting class member name before ‘@’

Possible problem call a function in onClick procedure by string from string.xml:

// function in Activity.java
public void myClickHandler(View view){
 
} 
 
// right implementation at onClick in activity.xml
<Button
                    android:onClick="myClickHandler"
 />
 
// bad impementaiton
<Button
                    android:onClick="@string/myClickHandler"
 />
Posted in Android Examples Code, Bugs, warnings, errors | Tagged , | Comments Off
370 views