android studio use 百度LBS have JNICommonMemCache

http://bbs.lbsyun.baidu.com/forum.php?mod=viewthread&tid=81792&page=1&extra=#pid142038

我已经在百度论坛说了,我就不复制过来了。。。

看了别人说,配置方式不一样。在AS配置那些so要像NDK那样配置  = =

http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/

上面是NDK配置

如果翻不了墙,就看我的把 = =

技术分享


在最后,我上传我的代码 = =供大家学习

//Fragment类

package org.moziqi.generic.company.fragment;

import android.os.Bundle;

import com.baidu.mapapi.map.SupportMapFragment;


public class ExploreFragment extends SupportMapFragment {


    private static final String ARG_SECTION_TITLE = "section_title";

    /**
     * 返回根据title参数创建的fragment
     */
    public static SupportMapFragment newInstance(String title, com.baidu.mapapi.map.BaiduMapOptions baiduMapOptions) {
        SupportMapFragment supportMapFragment = newInstance(baiduMapOptions);
        Bundle args = new Bundle();
        args.putString(ARG_SECTION_TITLE, title);
        supportMapFragment.setArguments(args);
        return supportMapFragment;
    }
}

//MainAcitivity的关键代码

==================================================================
fragments = new ArrayList<Fragment>();
MapStatus ms = new MapStatus.Builder().overlook(-20).zoom(15).build();
BaiduMapOptions bo = new BaiduMapOptions().mapStatus(ms)
                .compassEnabled(false).zoomControlsEnabled(false);
fragments.add(ExploreFragment.newInstance("发现", bo));
======================================================================
String[] itemTitle = getResources().getStringArray(R.array.item_title);
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        currentFragment = fragmentManager.findFragmentByTag(title);
        for (int i = 0; i < itemTitle.length; i++) {
            if (itemTitle[i].equals(title)) {
                if (currentFragment == null) {
                    currentFragment = fragments.get(i);
                    ft.add(R.id.container, currentFragment, title);
                }
                if (lastFragment != null) {
                    ft.hide(lastFragment);
                }
                if (currentFragment.isDetached()) {
                    ft.attach(currentFragment);
                }
                ft.show(currentFragment);
                lastFragment = currentFragment;
                ft.commit();
                onSectionAttached(title);
            }
        }
package org.moziqi.generic.common.constant;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;

import com.baidu.mapapi.SDKInitializer;

/**
 * Created by moziqi on 2015/1/29 0029.
 */
public class GenericApplication extends Application {

    private final static String TAG = "GenericApplication";

    private static GenericApplication instance;

    public static GenericApplication getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        SDKInitializer.initialize(this);
        instance = this;
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        showLog("系统处于匮乏状态");
    }

    @Override
    public void onTrimMemory(int level) {
        super.onTrimMemory(level);
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    /**
     * 打印土司
     *
     * @param msg
     */
    public static void showToast(String msg) {
        Toast.makeText(instance, msg, Toast.LENGTH_LONG).show();
    }

    /**
     * 打印日志
     *
     * @param msg
     */
    public static void showLog(String msg) {
        showLog(TAG, msg);
    }

    public static void showLog(String tag, String msg) {
        Log.e(tag, msg);
    }

    /**
     * 获取局部广播器
     *
     * @return
     */
    public static LocalBroadcastManager getLocalBroadcastManager() {
        LocalBroadcastManager instance1 = LocalBroadcastManager.getInstance(instance);
        return instance1;
    }

    public SharedPreferences sharePreference(String name, int mode) {
        SharedPreferences sharedPreferences = getSharedPreferences(name, mode);
        return sharedPreferences;
    }

    private SharedPreferences.Editor userEditor() {
        SharedPreferences user = sharePreference("user", Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = user.edit();
        return edit;
    }

    public void saveNewUserInfo(String username, String password) {
        SharedPreferences.Editor edit = userEditor();
        edit.putString("username", username);
        edit.putString("password", password);
        edit.commit();
    }

    public void deleteCurrentUserInfo() {
        SharedPreferences.Editor edit = userEditor();
        edit.remove("username");
        edit.remove("password");
        edit.commit();
    }
}


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。