user1345108
user1345108

Reputation: 230

admob compromising app

i'm making an app for android 2.2+ using facebook sdk too. my app is working fine and so before putting it on the market i decided to put some ads with admob. to use admob with previous version you have to compile with adnroid 32+ so that's what i did (i used api 15). in android 2.2-3.2 my app works and admob too, but in ICS (i'm testing it on a nexus with android 4.0.4) admob doesn't show any ads, some facebook requests give back a null result and some downloads of picture give error (i say "some" because other requests and other downloads of picture work..). I'll post here the relevant parts of my manifest and the other two errors. if remove ads and compile my app to 2.2 it begins to work fine again...

in my project.properties:

# Project target.
target=android-15

my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
package="com.***.***"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8"
          android:targetSdkVersion="15" 

   />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 <application
    android:icon="@drawable/icon_transparent_zk"
    android:label="***" >
<activity
        android:name="com.google.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

here's the request for facebook (i need it to get the user id):

String result_me = mFacebook.request("me");

and now the image, i can assure you that the url contained in the json is correct:

URL img_value = new URL(json.getString("pic"));
Bitmap icon = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());

if anyone could help me i'd really appreciate it! thank you

Upvotes: 1

Views: 323

Answers (1)

Tyler
Tyler

Reputation: 19848

Ice cream sandwich (or even Honeycomb if I recall correctly) doesnt allow you to perform network operations on the main thread.

Perform your admob requests in a Thread object.

(new Thread() {
    public void run() {
        //Admob stuff
    }
}).start();

This is to ensure you dont ANR your app on long network operations.

Upvotes: 1

Related Questions