64 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
66 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
345 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
186 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
142 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
779 views

Unable to execute dex: Multiple dex files define Eclipse Android

Try each step separately:

  1. Restart Eclipse
  2. Clean project and rebuild
  3. Create a new project and try it if the problem persists, if no move copy project to other folder, delete project from workspace , create new project same name and copy java, xml etc. files to new project
  4. Close Eclipse, backup folder c:\Users\myName\workspace\.metadata and delete it. Restart Eclipse try again import project to workspace
  5. Re-installing the Android Developer Tools
  6. Re-installing Eclipse – rename old folder with Android to Android_old, create new folder C:\Program Files\Android and copy new Eclipse with sdk into new folder
  7. Created a new project importing from the file system
  8. Created a new project from subversion
Posted in Bugs, warnings, errors, Eclipse | Comments Off
802 views

Ad baner without GoogleAdMobAdsSdkAndroid-6.4.1 Android example

First: AdView is in XML file

<com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="MY_AD_UNIT_ID"
    ads:adSize="BANNER"/>
 
// onResume
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("TEST_DEVICE_ID")
    .build();
adView.loadAd(adRequest);

Second: Using AdView in Fragment with LinearLayout
Resolve error in ADT Graphical layout editor:
The following classes could not be instantiated:
- com.google.android.gms.ads.AdView

// layout in xml file
    <LinearLayout
        android:id="@+id/layout"
              android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
// java class with fragment in Fragment class or in Activity class
private static AdView adView;
        @Override
		public void onResume(){  
                super.onResume();
                 try {
                	 // in xml is empty layout
					adView = new AdView(getActivity());
					adView.setAdUnitId("ca-app-pub-626/638103xxxxxxx");
					adView.setAdSize(AdSize.BANNER);  
 
                	                LinearLayout layout = (LinearLayout)getView() .findViewById(R.id.layout);
					layout.addView(adView);
 
					AdRequest adRequest = new AdRequest.Builder().build();   
					adView.loadAd(adRequest);
 
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
        }

More about:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration?hl=it

Posted in Android Examples Code | Tagged , , , | Comments Off
564 views

Importing google-play-service library project to workspace issue

Try two way in Eclipse IDE:

1.) Import the library project into your Eclipse workspace.
Click File > Import,
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
If project not visible with checkbox try next step as see below.

2.) Click
File > New > Other
select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.

Posted in Android Examples Code, Eclipse | Tagged | Comments Off
603 views

Every fragment must have an empty constructor Android Java Class

You have to add constructor!

    public static class YourFragment extends Fragment {
    //you have to add constructor!!!!!	
    public YourFragment(){}
 
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.activity_main, container, false);
 
            return view;
        }   
 
    }
Posted in Android Examples Code | Tagged | Comments Off
692 views

Difference between logical operators and or Java

Basic difference remember it!!!
if(TRUE && TRUE && TRUE) return TRUE otherwise FALSE

if(FALSE || FALSE || FALSE) return FALSE otherwise TRUE

Logical operator and &&
If all conditions/operands is TRUE return TRUE, otherwise return FALSE

if( true and true and true){ 
  // return true - do something
}
int a = 6;
if(a == 6 && a == 6 ) {
 // if TRUE
 // true && true return true, do something
}
 
if(a == 6 && a == 5){
  // nothing, not attended
}else{
  // true && false return false, do something
}

Logical operator or ||
The logical OR operator (||) returns the boolean value true if either or both operands is true and returns false otherwise.
If one operands is TRUE, condition is TRUE:

if(FALSE OR FALSE OR TRUE) return TRUE
if(FALSE OR TRUE OR FALSE) return TRUE
if(FALSE OR FALSE OR FALSE) return FALSE
 
int a = 6;
if(a==6 || a==5){ // TRUE || FALSE return TRUE
  //if return TRUE
  //one from operadns is TRUE return true,  do something
}
 
if(a==5 || a==4){ // FALSE || FALSE return FALSE
 // not attended
}else{
 //if return FALSE, do something
}

rev

Posted in Android Examples Code | Tagged , | Comments Off
692 views