How to embed map into our android application? - android

I was tried to embed google map into my android application. When I executed the application it display as below
could anyone help with this?. and my source code .
public class MainActivity extends MapActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
Here is my Manifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.mapp.MainActivity"
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>

You have just tried to develop with deprecated Google Maps Android API v1. This will not work for any new project since March.
Delete all the maps related code (seriously, this is the easiest path) and follow this https://developers.google.com/maps/documentation/android/start to use new Google Maps Android API v2.

Related

Android opens application without enough permission

I am starting to develop in Android and I am trying to understand Permissions, however the apps I made are not working and the "Dangerous" app is being opened even if the opener app doesn't have the required permissions to open it.
Dangerous manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.second_dangerousapp"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.dangerous_app.permission.DANGEROUS_ACTIVITY"
android:label="#string/label_dangerousActivity"
android:description="#string/description_dangerousActivity"
android:permissionGroup="android.permission-group.APP_INFO" >
</permission>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.second_dangerousapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.DANGEROUS_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The app itself is a simple textview with text.
Then the opener app
Permissions manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.second_permissions"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.second_permissions.MainActivity"
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>
And the code of the main activity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnOpen = (Button) findViewById(R.id.buttonOpen);
btnOpen.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent open = new Intent("android.intent.action.DANGEROUS_ACTIVITY");
startActivity(open);
}
});
}
What I am doing wrong. Cause right now the permission app shouldn't be able to open the dangerous app as it doesn't have the required permission.
Cause right now the permission app shouldn't be able to open the dangerous app as it doesn't have the required permission.
You are not defending anything in your app with the custom permission. Just having a <permission> element does nothing, other than define the permission. You also need to apply the permission somewhere, such as via an android:permission attribute on your <activity>.
You may also want to read this blog post about some unexpected behavior with respect to custom permissions.

android application crashes with no errors

i am trying out an android map application, when i run it there are no errors or problems in the code, i use my samsung galaxy s3 to test it but it keeps on displaying >"Unfortunately, maps has stopped".
Here's my java file
package com.maps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class Main extends MapActivity {
MapView map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = (MapView) findViewById(R.id.mvMain);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="AIzaSyAfv657yXaBMlBLAe2pw0VyJiPLiczDG7E"
android:id="#+id/mvMain"/>
</LinearLayout>
Here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name="com.maps.Main"
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>
A crash when using maps is often due to a bad API key. Double check that the key you are using is valid
Try to use Google Maps v2 for Android.
Here you have a good tutorial.
Anyway, your problem seems to be with the API key.
If GOOGLE API is not valid it will not show map that's it .
Why don't you attach your manifest.xml file so that we can rectify your error.
Otherwise check manifest file whether it contains reference of GOOGLEapi or not.

Display maps Android api V2

I'm triying to show a map in my app with the new api but all what i get is:
"Uknown issue with Google Play Services"
This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.monitoringsensors"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.INTERNET"/>
<permission
android:name="com.example.monitoringsensors.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.monitoringsensors.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<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"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name="com.example.monitoringsensors.Title"
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.example.monitoringsensors.HttpExample"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.HTTPEXAMPLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.monitoringsensors.TakeSomeData"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog">
<intent-filter>
<action android:name="android.intent.action.TAKESOMEDATA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCW3iv83siHrkWM6Q2qV4YcXk27CZWwmqc"></meta-data>
</application>
</manifest>
And this is the XML file:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
And the class is called like this:
public class HttpExample extends android.support.v4.app.FragmentActivity {...}
Thank you mates!
you need to verify map availability
Before you can interact with a GoogleMap object, you will need to confirm that an object can be instantiated, and that the Google Play services components are correctly installed on the target device. You can verify that the GoogleMap is available by calling the MapFragment.getMap() orMapView.getMap() methods and checking that the returned object is not null.
https://developers.google.com/maps/documentation/android/map#verify_map_availability
I personally use this code to check for Google Play Services, I test on both a real device running 2.3.3 and emulators on various versions of the OS, it prevents the emulators from breaking since they don't come with the updated Google Play Services that enables v2 of the Android Google Maps.
protected boolean readyToGo() {
String TAG_ERROR_DIALOG_FRAGMENT="errorDialog";
int status= GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (status == ConnectionResult.SUCCESS) {
return(true);
}
else if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
ErrorDialogFragment.newInstance(status)
.show(getSupportFragmentManager(),
TAG_ERROR_DIALOG_FRAGMENT);
}
else {
Toast.makeText(this, "no maps", Toast.LENGTH_LONG).show();
finish();
}
return(false);
}
It returns true if it's able to display the map, meaning the device has the required Google Play Services, or false if it does not, which is the case for the standard emulators in Eclipse and such right now.

adwhril sample not working

can anyone provide me a sample for integrating adwhril into android.I tried this sample
http://paste2.org/p/2168910
I used the same code as that one replacing the sdk key of mine But i am getting warnings saying
Can anyone suggest me
updated the code as suggested and got this warning
Yea, i have also faced this problem and solved in this way
Add those if you didn't already added in your menifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
In your activity where you want to show the add
<meta-data android:value="---- Your Key ----"
android:name="ADWHIRL_KEY"/>
Now add all the jar of the add provider you used, in your ad-whirl network. Add them to your app's libs folder and then add them to build path by right clicking on them from libs.
For example if you use Admob then add admob's jar to libs and add it to build path. And then add this line to menifest as this is needed to show add from admob individually or by using adwhirl
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
Now you will see the adds of admob.
Thank you
Ps: i have added the full code with image
Menifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.expadwhirl"
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"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:value="2f120f401e9a40d0afa55557d3a3a58c"
android:name="ADWHIRL_KEY"/>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
</application>
</manifest>
Layout
<RelativeLayout 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" >
<com.adwhirl.AdWhirlLayout
android:id="#+id/adwrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
Activity
import android.app.Activity;
import android.os.Bundle;
import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlLayout.AdWhirlInterface;
public class MainActivity extends Activity implements AdWhirlInterface {
AdWhirlLayout adwrl;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public void adWhirlGeneric() {
// TODO Auto-generated method stub
}
}
Overall project

Google Maps API in Android--using a proxy server

I am trying to develop a simple app using Google maps.
While running the app i can see only the grid and the map controls.
I did obtain an API key and included it into main.xml file.
The permissions for the internet was also granted in the androidmanifest.xml.
My browser in avd is connecting to internet and when i run the native map app in the avd, it shows the following error.
**Network Failure ... Wrong remote strings version.GMM Server must be hosting:/strings_remote_533149424.dat**
GoogleMapActivity.java
package com.example.googlemap;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class GoogleMapActivity extends MapActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
#Override
protected boolean isRouteDisplayed()
{
return false;
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<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="0kuSQz9hsxal-_JpKGJbFp__zLqhl5d4gG3ohDg"
/>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemap"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".GoogleMapActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</application>
</manifest>
I'm using a proxy to connect to the internet.
Can anyone plz help me out with this..plz help me!!
As far as I know about GoogleMaps, there are no indications in manuals if the proxy could matter in displaying maps. If you got the map controls and the GoogleMap grid, this means that you have been connected to the map server but map tiles permissions were denied to you. What to do:
1. Check it if you got the DEBUG key or the Release key
2. Use the Debug key if you are testing locally with the "apk" downloaded from your PC
3. Use the Release key if you are debugging your "apk" downloaded from the Android market
It looks like you are stumbling upon one of the upper bottle-necks.
If these indications did not work, show your settings and source code on this forum for others to react appropriately.
Did you set this permision in manifest: android.permission.ACCESS_FINE_LOCATION, android.permission.ACCESS_COARSE_LOCATION and in aplication ???
I revisited your question and found 2 possible flaws.
Rewrite your manifest file as follows. USES-PERMISSION tags should be out of the APPLICATION tags.
Possibly, you may have been using a wrong debug-key. Please, generate an new debug-key according to manuals to use with this application on development PC.
If the problem persists, please update your development environment to the latest and test again.
Your rewritten manifest.xml should look like the following:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemap"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".GoogleMapActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Categories

Resources