SupportMapFragment Instead of MapFragment - android

I want to make an android application that uses Google Maps for Android v2.
I can show a map. I can even navigate and zoom. But, when I want to search for more operations to make, I can't find any.
I want this application to work on API level 8 and above. So, I used SupportMapFragment. I heard that, if I want to make my application to work on API level 8 and above, I have to use SupporMapFragment.
I found examples about MapFragments, but unfortunately, not about SupportMapFragment.
I want to make these operations work in my application, however, they're using MapFragment:
One
Two
Is there a way of doing things like, "add marker", "show my current location", and "take position of the point that I clicked"? (using SupportMapFragment, of course. )
Thank you very much already.

Is there a way of doing things like, "add marker", "show my current location", and "take position of the point that I clicked"? (using SupportMapFragment, of course. )
Yes.
Step #1: Add the Android Support package to your app.
Step #2: Have your activities inherit from FragmentActivity from the Android Support package.
Step #3: Change all MapFragment references (Java code and layout XML resources) to SupportMapFragment.
And you're done.
All of my Maps V2 samples use SupportMapFragment, in conjunction with ActionBarSherlock (which is why you will see SherlockFragmentActivity as opposed to FragmentActivity.

Related

Is it OK to show google map API without actually showing a map?

I would like to use google map API to get a map canvas to put objects on it, but not showing the map, by using the maptype NONE.
Am I allowed to do that in an Android app using v2 and distribute it?
This is what I want to do:
#Override
public void onMapReady(GoogleMap map) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(-18.142, 178.431), 2));
// Other supported types include: MAP_TYPE_NORMAL,
// MAP_TYPE_TERRAIN, MAP_TYPE_HYBRID and MAP_TYPE_SATELLITE
map.setMapType(GoogleMap.MAP_TYPE_NONE);
}
I want to set map.setMapType(GoogleMap.MAP_TYPE_NONE); and then add various markers to the map, including my current position
Added a picture to show what I want to achieve.
As mentioned in Google documentation it's forbidden. More over - From what you are saying it seems that you want use gmaps capabilities to get data and calculations but actually display some thing else. I really don't think it's good idea. However - if the issue is making geo calculations, consider to use 3'rd party open source libs for this. For example http://www.gavaghan.org/blog/free-source-code/geodesy-library-vincentys-formula-java/

Change the title of Paypal PaymentActivity class

I included paypal sdk in the app and set the product name and price as shown in the attached image.
Is it possible to change the title of the paypal PaymentActivity class . ?
I used the entire code for paypal from this link
.Please suggest whether we could change the title to any text ,(I want to change the text that is marked in Red Circle)?
Jeff here from the PayPal Mobile SDK team.
The PayPal Android SDK doesn't support modifying any of the SDK activities. We don't plan to allow the ability to modify titles, as this would be an inconsistent user experience. However, we're open to feedback from users, so please feel free to file issues in GitHub if you have feature requests!
Couple observations, apparently:
The activity of off which you have put screenshot is PaymentMethodActivity (according to Hierarchy Viewer)
PayPal SDK uses ABS
According to the sample app provided in PayPal SDK page, onBuyPressed() launches PaymentActivity with startActivityForResult():
Now, according to SDK references, PaymentActivity does not provide any API for setting custom title. The page lists setTitle() as a part of "Methods inherited from class android.app.Activity", but does not give any details on how to extend PaymentActivity so that one could leverage those APIs.
So, currently, there is no way to use a custom title.
I personally would not bother to change the title on that screen as it clearly depicts itself as a PayPal screen (as one would see their homepage on a browser), but if you really want a custom title, you may need to file a new issue on their GitHub page.
Your AndroidManifest.xml file should have an entry for the PaymentActivity that looks like this:
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
All you should have to do is add the label attribute to that to change the title:
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" android:label="#string/some_title" />
For other potentially useful attributes, refer to the activity tag documentation.
Note: I'm assuming here that the PayPal SDK will allow you to override the title. That is, I would expect it to only set a default title if none is given explicitly.
Edit: Unfortunately, the assumption above has proven to be incorrect. Diving a little deeper, it turns out every activity in the PayPal SDK always sets its title in the onCreate() method. That's actually a little surprising, because that means that PayPal isn't leveraging Android's built-in support for localisation and resources. Although I suppose it does allow them to offer developers the SDK as a jar, which doesn't support bundling Android resources.
In any case, since the various activities haven't been declared final, you could simply try to extend them and set the title after the super has done its work:
public class TitlePaymentMethodActivity extends PaymentMethodActivity {
#Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Custom Title")
// or:
setTitle(R.string.custom_title);
}
}
After that, you'll have to change the manifest to point to your TitlePaymentMethodActivity, in stead of directly to the activity in the SDK. Do note that this approach may break at any point, if PayPal decides to finalize the activity classes. With that in mind, I suggest you follow #shoe rat's recommendation and file a request with PayPal for 'official' support.

Using numberPickerView with differant APIs

In some old APIs numberPickerView not Working.So if i use this view in a project manifest have to be set to higher.That means program not working in old APIs.So my questions are
Is there any View give same functionality in all APIs in Android?
Or is any way to show NumberPickerView in layout when run in latest APIs and show another view to enter numbers(Like EditText) in the place of NumberPickerView when running on older version?
It was added in api 11. If you want pre-11, check this code:
https://github.com/michaelrnovak/numberpicker
You're welcome.

How to implement Google Maps API v2 to Android Application without it crashing?

I am trying to make an application as a school project and I MUST implement Google Maps. I am fairly new to Android coding and now little of Java. So far I created this application using Google Maps API v2, I obtained a key, I added all the permissions and code in the manifest, I added the default Google example code to make a map simply appear but I get a crash and lots of errors when running the application. I also added existing code and set it to project library, I set target and compile with to be specifically with the API's. I keep "banging my head" trying to get this to work. I saw other questions have similar problems but resolved with something I already have completed.
Since I'm having troubles adding code by text, I hope you guys can understand I used exactly what Google posted as their tutorial. I can't do images due to my rep.
I managed to fix this thanks to newbostonforums and I am adding my findings for anyone else seeking help. You need to add google-play-services_lib to your project.
Right click IMPORT
Android->Existing Code->(SDK/extras/google/google_play_services/libproject/google-play-services_lib)
Right click on project. Properties->Android->Library-ADD->(SDK/extras/google/google_play_services/libproject/google-play-services_lib
Once you added the folder it will be "linked" with the project.
In JAVA you must add
MAKE SURE YOU IMPORT ALL RED UNDERLINED.
public class Main extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, fragment).commit();
Then your XML can be at your choosing but it must include
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.SupportMapFragment"
// POSSIBLY OPTIONAL
android:id="#+id/map"
You may replace android:name with class but I don't know the difference. I believe they both work.
However there are many ways to make it work and I am somewhat changing this method.

how can i set Street view for Google map in Android?

For Displaying the street view in the map i am putting the following code:
mapView.setStreetView(true);
But, it is not executed it shows the following message when i write the method.
The method setStreetView(boolean) from the type MapView is deprecated
Is there any alternative for that?
No other alternative yet in place of setStreetView(boolean) method from google api 11 onwards, but if you read document carefully, it will show you blue line if street view is available of particular place
There is NO alternative because isStreetView(boolean) is NOT deprecated. I have used this method on several phones running Android 4.0.4 and it works on ALL of them. Perhaps it is deprecated on some phones but not on the Galaxy Nexus. isStreetView(boolean) works, so use it.

Categories

Resources