I am trying to add addwhirl in my app but I doesnt show up any ads, I am doing following things
Manifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.liverpool.activities"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/layout_ad" />
in code I am doing following
try
{
AdManager.setTestDevices(new String[] { AdManager.TEST_EMULATOR });
LinearLayout layout = (LinearLayout) findViewById(R.id.layout_ad);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "SDK key from adwhirl");
Display d = this.getWindowManager().getDefaultDisplay();
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(d.getWidth(), 72);
layout.addView(adWhirlLayout, adWhirlLayoutParams);
}
catch (Exception e)
{
}
where I am doing wrong?
Remember you only really need the INTERNET permission. The rest is optional. You shouldn't ask for GPS location unless your app needs it. If you do it just for the ads you'll get negative reactions from your users. And trust me adding more geo targeting will not increase your revenue.
There is nothing wrong with the above code.
Problem is that I haven't configured the adwhirl page with ads provider settings its very fool to miss such thing
Related
I have little experience in programming for android, so I turn to you. The fact is that I created a program for myself to practice my skills. Right now I have one ListView and the ListView has one ImageView and a TextView to fill in successfully through an Adapter. On ImageView I get a picture from the server, the problem is that when the server is local everything works fine, but if the real server then the picture does not load.
url="http://192.168.0.1/image/" or url="http://mysite/image/"
view = inflter.inflate(R.layout.list_item, null);
final ImageView icon = (ImageView) view.findViewById(R.id.GoodsIcon);
try {
Glide.with(url+GoodsList[i].GOODS_MEDIUM_IMAGE_NAME).into(icon);
} catch (Resources.NotFoundException e) {
Toast.makeText(view.getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
try catch does not catch errors, even when the server is real.
<ImageView
android:id="#+id/GoodsIcon"
android:layout_width="100dp"
android:layout_height="130dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="2dp"
android:adjustViewBounds="true"
android:fontFamily="#font/bebas_neue_light"
android:scaleType="fitEnd" />
In the manifest I have already added all access.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Notes: I also take the text for the TextView from the server, even on the real server the text loads successfully
I currently have this code in an app that uses Google maps:
<uses-permission android:name="com.example.app.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
I have started to wonder though, if I set all these to required="false" the app would presumbly generated a shorter "requires" list when users download the app... Is there any reason not to just set them all to not required?
Currently I do this when loading maps
private void setUpMapGoogleIfNeeded() {
if (mMapGoogle == null) {
mFragmentManager = getSupportFragmentManager();
mSupportMapFragment = (SupportMapFragment) mFragmentManager.findFragmentById(R.id.mapFragment);
mMapGoogle = mSupportMapFragment.getMap();
if (mMapGoogle != null) {
mMapGoogle.setMyLocationEnabled(SharedCode.sharedSupportsGPS(true, thisActivityContext));
}
}
Does anyone have experience with this? Are the siuttations I have not thought of where setting required = false for above menions can cause errors/exceptions in my app?
There is no android:required attribute for <uses-permission> and so it will be ignored. It will not result in "a shorter "requires" list when users download the app".
I am creating an android application that uses google maps api v2.
I believe I have done everything as google tutorial sais but still I am getting only the google maps grid (no map). I have created a debug key from using SHA1 of keystore.debug.
below are my settings:
Eclipse java compiler version 1.7
Project java compiler version 1.6
application manifest:
<manifest ...>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="my.app.test.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application>
<activity>
...
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxx"/>
<uses-library android:name="com.google.android.maps"/>
</application>
</manifest>
Map xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/BackGroundColor"
android:orientation="vertical"
tools:context=".test" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingRight="10dp"
android:paddingTop="5dp" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="xxxxxxxxxxxxxxxxxxxxxxxxxx" >
</com.google.android.maps.MapView>
</LinearLayout>
</LinearLayout>
Map Activity:
public class Map extends MapActivity {
MapView mapView;
MapController mc;
GeoPoint p;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_map);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setStreetView(true);
mc = mapView.getController();
String coordinates[] = {"1.352566007", "103.78921587"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);
p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));
mc.animateTo(p);
mc.setZoom(17);
mapView.invalidate();
}
#Override
protected boolean isRouteDisplayed() { return false; }
}
I know that there are plenty of post with the same problem. I have read them all!!!
I have created the key several times but still the same...
Any ideas what is wrong and I am only seeing the grid? the application has the same outcome to AVD as well as to a Samsung mobile with android version 2.2.1
If you writing you application for API V2 then you are using the wrong objects, few things you need to fix:
1. Remove this:
<uses-library android:name="com.google.android.maps"/>
it's a permission for Google Map API V1.
2. you have to add this 2 permissions:
<permission android:name="your.application.package.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="your.application.package.permission.MAPS_RECEIVE"/>
change: your.application.package to your current application package.
3. As you targeting SDK v8, you have to add fragment support to your application in order to use the SupportMapFragment from Google Map API V2, So you need to add google-support-v4 and change your map object to SupportMapFragment.
4. Your MapActivity has to be changed to FragmentActivity.
5. You can can get more information on how to make those changes in a blog post I wrote on how to add Google Map API V2 to your project:
Google Maps API V2
Your problem is related with the emulator, you need to install to APK's.
I had similar problems so I prepared step by step tutorial to show how you can use google map android v2 on emulator(android 4.2.2) have a look at to my blog: http://umut.tekguc.info/en/content/google-android-map-v2-step-step
You need to generate MD5 fingerprint from java keytool instead of SHA1.
Check this post to generate MD5 fingerprint:
How can I get the MD5 fingerprint from Java's keytool, not only SHA-1?
I wanted to try out having OpenStreetMap integration by osmdroid, but I got stuck at an issue where I have no idea what is missing. The scenario is as follows:
Symptom: Map widget gets displayed but only with an empty grid.
This is in my Activity class:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this, 256);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
setContentView(mapView);
}
(I tried selecting various TileSources with seemingly no difference)
My Manifest also includes these permissions (as a child of <manifest>, after <uses-sdk>):
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...and my emulator is otherwise connected to the internet, eg. web browsers work.
osmdroid and slf4j are in the build path. The app compiles without a problem and generates no exceptions.
What could be wrong?
Many thanks!
SOLVED: This was caused by my emulator not having an external storage to cache map tiles.
I'm pretty new to OSMdroid too but try doing this?
setContentView(R.layout.offline_map_activity);
mapView = (MapView) findViewById(R.id.openmapview);
You would also need to have offline_map_activity.xml in your res/layouts:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<org.osmdroid.views.MapView
android:id="#+id/openmapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
Hope this works for you. At least this worked for my codes :)
i tink your Device has don't SD. You have change the Cache Path
OpenStreetMapTileProviderConstants.setCachePath(this.getFilesDir().getAbsolutePath());
Been having some trouble trying to integrate the admob sdk into my application to display ads. Im using the AdmobSDK version 4.1.0. I've read loads of posts and there seems to be lacking some decent documentation and many discussions on the topic including http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/3b885d3fe5bb21a5?pli=1 So far my layout is..
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<com.google.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_PUB_CODE"
ads:adSize="BANNER"/>
</LinearLayout>
</ScrollView>
my androidmanifest.xml contains...
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"></activity>
<meta-data android:value="MY_PUBLISHER_ID" android:name="ADMOB_PUBLISHER_ID"></meta-data>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
EDIT, UPDATE:
Ok i seem to have gotten admob working on my HTC by adding,
AdView ad = (AdView) findViewById(R.id.ad);
AdRequest r = new AdRequest()
r.addTestDevice("X3XFX518X7DE1FD879XA5XXAX1AX8BXX");
ad.loadAd(r);
however i only recieve a test banner, stating im ready to explore the google app galaxy. When i remove the "addTestDevice" method, the banner/ad does not show up atal and in the log i recieve, "ad not recieved due to lack of inventory" .. Anyone sheed some light on this?
thanks for the help so far!
To your comment, I use this and it works quite well for me. The size is the second param of the AdView constructor.
ad = new AdView(this, AdSize.BANNER, "<ID>");
LinearLayout layout = (LinearLayout) findViewById(R.id.main_admob_layout);
// Add the adView to it
layout.addView(ad);
AdRequest request = new AdRequest();
request.setTesting(TESTING_MODE);
ad.loadAd(request);