Android launching a MapActivity? - android

I'm trying to set up the google maps API for an application. I'm following this link:
http://developer.android.com/guide/tutorials/views/hello-mapview.html
Yes, I got my own APK key in the xml and added all the manifest stuff they wanted. But my Java code is giving me an error:
import android.app.Activity;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.maps.MapActivity;
public class PathTracker extends MapActivity {
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
Apparently MapActivity is an undefined class, and my last import doesn't help.
Can anyone help me access the MapActivity class?
Thanks.

You need to use the Google APIs SDK instead of the plain Android SDK. You can download this SDK (the one that matches the API level you want) from the android application in the sdk tools. Then edit your project in Eclipse and use that as the SDK.
Go to the android tool (from Eclipse, go to Window -> Android SDK and AVD Manager) or look for the executable in the android sdk directory.
Select Available packages, expand Third party add-ons, expand Google Inc, select the one you want, and download it.
Back in Eclipse, right click your project, select properties. Under the Android menu, select the SDK you downloaded in step 2 as the target.

Related

Import the facebook sdk (4.17.0) with no gradle inside into an android studio's project

I am trying to import the latest Facebook SDK (4.17.0 at the moment) but i noticed that the zip file is built differently than the formers Facebook SDK.
And when i'm trying to import it into android studio by going : File>> New>> Import Module, it gives me an eror message for the lastest fbk sdk : "Specify location of the Gradle.
Screenshot : import error
I'm still new to android programmation, so i'm asking for your help to import the lastest Facebook sdk.
Thank you by advance guys.
Screenshots of the zip comp :root
I up this question.
And i add some other question to it : on every example of Facebook sdk import i found, its mentioned that we need to create a new project in order to import fbk sdk. Is it just for the example? do we really need to create a new project to import the sdk, or can we just import it in an existing project ?

Android Studio: Select min sdk version not working?

I was trying to select min sdk version to 11. After I finish creating the project, the main activity still shows I am importing v7 ActionBarActivity:
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
public class MainActivity extends ActionBarActivity {
...
Did I configure something wrong?
Thanks
Open your build.gradle file and make sure that minSdkVersion is set to 11.
Click the Sync Gradle Files button on the toolbar to the left of the SDK manager
the Gradle files will now be automatically re-imported
Clean and Rebuild your project
For those using Android Studio 0.8.6 and having the same issue while following Google's tutorials, what worked for me was to add this line under "dependecies" in your module build.gradle file:
dependencies {
compile 'com.android.support:appcompat-v7:20.0.0'
}
it worked for me!
:)
No, android studio import it automatically because there are some features that worked since version 14.
For example: when you set the actionbar in your XML document and you want to hide / show some item you use "android:showAsAction" attribute, but the compiler generates an error, because that works only on version 14 and later.
So, the compiler tells you that you have to change it in "yourapp:showAsAction" (because you declared to support version 11) where "yourapp" is a namespace that you've imported in your xml file:
xmlns:yourapp="http://schemas.android.com/apk/res-auto
Remember that "yourapp" can be every name you want! Well, now if you test your app you find out that show / hide functionality doesn't work properly, and this is because your activity doesn't extends ActionBarActivity. This is why androidStudio automatically extends ActionBarActivity when you declare a minSdk of 11.
Hope this post was useful, bye!

Android SDK Fragment Support

Ok i'm just starting to get into Android programming now, and I'm following the android "TabActivity" tutorial: http://developer.android.com/reference/android/app/TabActivity.html.
Everythings working but it can't seem to find some of the support classes, see the code below that is generating the errors.
mTabManager.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
FragmentStackSupport.CountingFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
LoaderCursorSupport.CursorLoaderListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
LoaderCustomSupport.AppListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
LoaderThrottleSupport.ThrottledLoaderListFragment.class,null);
For FragmentStackSupport/LoaderCursorSupport/LoaderCustomSupport/LoaderThrottleSupport, it says for all of them cannot be resolved to a type. I've added the latest support library to a folder in the root directory named "libs" and also coppied it into "C:/Eclipse/v4/" directory. My import files are:
import java.util.HashMap;
import android.R;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.View;
import android.widget.TabHost;
import cowdawg.hello_tab.namespace.R.layout;
import cowdawg.hello_tab.namespace.R.id;
Could someone please offer me some advice on how to solve this, thanks :).
It's probably because the following classes are not part of the standard Android API (or the support library), but only exist in the support demos sample code for demonstration purposes:
FragmentStackSupport.CountingFragment
LoaderCursorSupport.CursorLoaderListFragment
LoaderCustomSupport.AppListFragment
LoaderThrottleSupport.ThrottledLoaderListFragment
You will need to add these classes to your own project in order to be able to use them. Here you can find the source files under the subsection 'Files'.
FragmentStackSupport
LoaderCursorSupport
LoaderCustomSupport
LoaderThrottleSupport
On Eclipse IDE: Select your project and then right click on the project -> Android Tools -> Add Support Library.
Required support library will be added on your project build path. You will found this library jar under Java Build Path -> Libraries tab -> Android Dependencies.
Enjoy exploring!
Have you added the library to your build path? Right click on the jar in eclipse -> Build Path -> Add to Build Path.
Try adding by right clicking on the project and opening properties window
Instead of these missing classes you can create your own by subclassing Fragment class (or its subclasses like DialogFragment, ListFragment etc). More info is provided by Android here.

how to import android licensed project in eclipse?

Can anyone help me to know how to import licensed project, while trying... the following classes cannot be imported.
import com.android.vending.licensing.LicenseChecker;
import com.android.vending.licensing.LicenseCheckerCallback;
import com.android.vending.licensing.ServerManagedPolicy;
import com.android.vending.licensing.AESObfuscator;
Any help will really be appreciated. Thanks
The latest version of the LVL seems to require
import com.google.android.vending.licensing.LicenseChecker;
import com.google.android.vending.licensing.LicenseCheckerCallback;
import com.google.android.vending.licensing.ServerManagedPolicy;
import com.google.android.vending.licensing.AESObfuscator;
instead of
import com.android.vending.licensing.LicenseChecker;
...
(as the current document tells me to do)
It took me a half day to figure this out.. haha
LVL library can be downloaded using the SDK Manager
Link
The License Verification Library (LVL) is a collection of helper classes that greatly simplify the work that you need to do to add licensing to your application. In all cases, we recommend that you download the LVL and use it as the basis for the licensing implementation in your application.
The LVL is available as a downloadable component of the Android SDK. The component includes:
The LVL sources, stored inside an Android library project.
An example application called "sample" that depends on the LVL library project. The example illustrates how an application uses the library helper classes to check and enforce licensing.
To download the LVL component into your development environment, use the Android SDK and AVD Manager. Launch the Android SDK and AVD Manager and then select the "Market Licensing" component, as shown in the figure below. Accept the terms and click Install Selected to begin the download.

implementing location based services

i am trying to implement this tutorial but i am getting errors in these line
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
in WhereAreMyFriendsMap.java
Is there anything else like jar i need to add
Thanks
You have to set your Project Build Target to the Google APIs version of the API level you're targeting. You most likely have it set to Android API.
From the same tutorial, do you have everything they mentioned here?
Getting started is pretty well-worn ground. Pull down the latest Android SDK and JDK (5 or newer). Download and install Eclipse for Java developers (3.2 or newer) and the ADT Eclipse plugin and you're set. There's more detail at StackOverflow, on the Android code site, and the Android support forums.

Categories

Resources