Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

AdMob in Android 4 version


AD MOB

AdMob in Android emulator not visible?
You have to using some from this libraries:
GoogleAdMobAdsSdk-4.3.1.jar
GoogleAdMobAdsSdk-6.0.1.jar
GoogleAdMobAdsSdk-6.2.1.jar

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
    package="cz.okhelp.admob"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="13"
        android:targetSdkVersion="16"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
   

    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
       <meta-data 
        android:value="a14d932xxxxxxxx" 
        android:name="ADMOB_PUBLISHER_ID" />
        <activity android:name=".AdmobActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

<activity android:name="com.google.ads.AdActivity"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>


onCreate in your Activity.java

		@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     			AdViw adView = new AdView(this, AdSize.BANNER, "a14d932xxxxxxxxx");//MY_AD_UNIT_ID
    			LinearLayout layout = (LinearLayout)findViewById(R.id.idReklamaLayout);
				// Add the adView to it
    			layout.addView(adView);
				// Initiate a generic request to load it with an ad
				AdRequest adRequest = new AdRequest();
    			//adRequest.setTesting(true);
    			adRequest.setGender(AdRequest.Gender.MALE);
    			adView.loadAd(adRequest);
    }



main.xml (res/layout)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:id="@+id/idReklamaLayout"
android:orientation="vertical"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="3" />

</LinearLayout>

397LW NO topic_id




AD

Další témata ....(Topics)


342

Android Studio add library dependencies to module project | android-studio-add-library-dependencies-to-module-project



  1. File->Project Structure Ctrl + Alt + Shift + S


  2. Select module and Dependencies Tab


  3. Click on + PLUS button (right upper corner)


  4. Select library


  5. Click OK, OK





android-studio-add-library-into-project.png
175

Statistics usability of mobile phones with Android – February 2012 | statistics-usability-of-mobile-phones-with-android-%e2%80%93-february-2012


Table of usability of mobile phones with Android – February 2012 - (application Sky Map)















1 Samsung Galaxy S2 6.3%
2 HTC Desire HD 3.5%
3 HTC Evo 4G 3.4%
4 Samsung Galaxy Ace 2.1%
5 Samsung Galaxy S (SCH-I500) 2.1%
6 Samsung Galaxy S (GT-I9000) 2.1%
7 HTC Incredible 2 2.0%
8 Motorola Droid X 1.9%
9 Motorola Droid RAZR 1.9%
10 HTC Sensation 4G 1.7%

72

While cycle loop in Java example | while-cycle-loop-in-java-example


While cycle Java basic example with array of strings.

MainClass.java

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = { "Hello", "people", "hello", "world!" };
                int i = 0;
		while ( i < arrayOfString.length ){
			System.out.println(arrayOfString[i]);
			i++;
		}
	}
}
339

ActivityThread: Failed to find provider Sqlite database | activitythread-failed-to-find-provider-sqlite-database


Issue:
ActivityThread: Failed to find provider

Try check this authority tags if they are all the same:
(com.yourdomen.yourproject.YourContentProviderClass replace your path to YourContentProviderClass)

res/xml/serchable.xml
Tag searchable

<searchable xmlns:android="//schemas.android.com/apk/res/android"
android:blahblah 
......
android:searchSuggestAuthority="com.yourdomen.yourproject.YourContentProviderClass"


AndroidManifest.xml
Tag provider

 <provider android:name=".YourContentProviderClass"
                  android:authorities="com.yourdomen.yourproject.YourContentProviderClass" />

108

Turn screen ON OFF Android sample code | turn-screen-on-off-android-sample-code


WakeLock, PowerManager,uses-permission Android sample.
Main.java

public class Main extends Activity {
	    private SensorManager mSensorManager;
	    private PowerManager mPowerManager;
	    private WindowManager mWindowManager;
	    private WakeLock mWakeLock;
	    private Button button;
	    private TextView textView;

	    /** Called when the activity is first created. */
	    @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
try{
	        // Get an instance of the SensorManager
	        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

	        // Get an instance of the PowerManager
	        mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);

	        // Get an instance of the WindowManager
	        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
	        mWindowManager.getDefaultDisplay();

	        // Create a bright wake lock
	        mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()
	                .getName());

	        setContentView(R.layout.main);
	        textView = (TextView)findViewById(R.id.textView1);
	        button = (Button)findViewById(R.id.button1);
	        button.setOnClickListener(mButtonStopListener);
	       
	        
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			Log.e("onCreate", e.getMessage());
		}
} // END onCreate
	    
	    View.OnClickListener mButtonStopListener = new OnClickListener() {
	    	public void onClick(View v) {
		        try {
					mWakeLock.release();
					textView.setText("mWakeLock.release()");
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					Log.e("onPause",e.getMessage());
				}
	    	
	    	}
	    };

	    @Override
	    protected void onResume() {
	        super.onResume();
	        /*
	         * when the activity is resumed, we acquire a wake-lock so that the
	         * screen stays on, since the user will likely not be fiddling with the
	         * screen or buttons.
	         */
	        
	        try {
				mWakeLock.acquire();
				textView.setText("mWakeLock.acquire()");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Log.e("onResume", e.getMessage());
			}

	    }

	    @Override
	    protected void onPause() {
	        super.onPause();

	        // and release our wake-lock
	        try {
				mWakeLock.release();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Log.e("onPause",e.getMessage());
			}
	    }
}



AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
      package="cz.okhelp.Main"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.HARDWARE_TEST"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>

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

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".ScreenBrightnessActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>




Editace: 2012-12-20 23:05:17
Počet článků v kategorii: 397
Url:admob-in-android-4-version

AD
11 Share
Share
Tweet