为Sony Small App开发谷歌地图

时间:2014-06-05 08:54:17

标签: android google-maps sony

sony小应用程序支持Android谷歌地图?当我尝试为小应用程序运行一个简单的地图时,我有以下错误。可能是“getFragmentManager()”只支持活动而sony小应用程序正在运行“服务类”而不是“活动类”?

由SmallApplication扩展的类

package com.ccs.cmapsmallapp;
import com.ccs.cmapsmallapp.R;
import com.google.android.gms.maps.GoogleMap;
import com.sony.smallapp.SmallAppWindow;
import com.sony.smallapp.SmallApplication;


public class ActivityMap extends SmallApplication {
    private GoogleMap map;

    @Override public void onCreate() { 
        super.onCreate(); 
        setContentView(R.layout.map); 
        setTitle(R.string.app_name); 

        int intDisplayWidth = getResources().getDisplayMetrics().widthPixels;
        int intDisplayHeight = getResources().getDisplayMetrics().heightPixels;

        SmallAppWindow.Attributes attr = getWindow().getAttributes(); 
        /* Set the requested width of the application. */ 
        attr.width = getResources().getDimensionPixelSize((int)(intDisplayWidth*0.4)); 
        /* Set the requested height of the application. */ 
        attr.height = getResources().getDimensionPixelSize((int)(intDisplayHeight*0.4)); 
        /* Use this flag to make the application window to be resizable */ 
        attr.flags |= SmallAppWindow.Attributes.FLAG_RESIZABLE; 
        /* Use this flag to remove the titlebar from the window */ 
        //attr.flags |= SmallAppWindow.Attributes.FLAG_NO_TITLEBAR; 
        /* Set the window attributes to apply the changes above */ 
        getWindow().setAttributes(attr); 

    }
    @Override public void onStart() { 
        super.onStart(); 
    } 
    @Override public void onStop() { 
        super.onStop(); 
    } 
    @Override public void onDestroy() { 
        super.onDestroy(); 
    }
}

我的xml布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >            
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />       
</LinearLayout>

清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ccs.cmapsmallapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19" />

    <!-- Google Map permission-->
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!-- Normal Permission -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.sony.smallapp.permission.SMALLAPP" /> 
    <application 
        android:label="@string/app_name" 
        android:icon="@drawable/ic_launcher"> 
        <uses-library android:name="com.sony.smallapp.framework" /> 
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyBYL5KEfdm03wHgsdvguusI9-NMWvM1Lzc"/>
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version"/>
        <service 
            android:name="com.ccs.cmapsmallapp.ActivityMap" 
            android:exported="true"> 
            <intent-filter> 
                <action android:name="com.sony.smallapp.intent.action.MAIN" /> 
            <category android:name="com.sony.smallapp.intent.category.LAUNCHER"/> 
            </intent-filter> 
        </service> 
    </application>
</manifest>

错误:

06-05 16:38:43.015: E/AndroidRuntime(16549): FATAL EXCEPTION: main
06-05 16:38:43.015: E/AndroidRuntime(16549): Process: com.ccs.cmapsmallapp, PID: 16549
06-05 16:38:43.015: E/AndroidRuntime(16549): java.lang.RuntimeException: Unable to create service com.ccs.cmapsmallapp.ActivityMap: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2644)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.app.ActivityThread.access$1800(ActivityThread.java:144)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.os.Looper.loop(Looper.java:212)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.app.ActivityThread.main(ActivityThread.java:5151)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at java.lang.reflect.Method.invokeNative(Native Method)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at java.lang.reflect.Method.invoke(Method.java:515)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at dalvik.system.NativeStart.main(Native Method)
06-05 16:38:43.015: E/AndroidRuntime(16549): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at com.sony.smallapp.SmallAppWindowImpl.setContentViewInternal(SmallAppWindowImpl.java:862)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at com.sony.smallapp.SmallApplication.setContentView(SmallApplication.java:470)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at com.ccs.cmapsmallapp.ActivityMap.onCreate(ActivityMap.java:13)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2634)
06-05 16:38:43.015: E/AndroidRuntime(16549):    ... 10 more
06-05 16:38:43.015: E/AndroidRuntime(16549): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.fragment" on path: DexPathList[[zip file "/system/framework/com.sony.smallapp.jar", zip file "/data/app/com.ccs.cmapsmallapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.ccs.cmapsmallapp-1, /vendor/lib, /system/lib]]
06-05 16:38:43.015: E/AndroidRuntime(16549):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.createView(LayoutInflater.java:559)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
06-05 16:38:43.015: E/AndroidRuntime(16549):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
06-05 16:38:43.015: E/AndroidRuntime(16549):    ... 17 more

0 个答案:

没有答案