当前位置: 编程技术>移动开发
本页文章导读:
▪获取运用运行次数 获取应用运行次数
PackageManager manager = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN);
List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
List<ComponentName> names = new ArrayL.........
▪ 关于省市的多级联动有关问题 关于省市的多级联动问题
写了个测试 使用gson进行数据的解析 代码如下: String[] array = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y",.........
▪ CCLayer的一部分显示 CCLayer的部分显示
void YourLayer::visit(){ glEnable(GL_SCISSOR_TEST); float floatScale = CC_CONTENT_SCALE_FACTOR();glScissor(x * floatScale,y * floatScale,width * floatScale,height * floatScale);CCLayer::visit(); glDisable(GL_SCISSOR_TE.........
[1]获取运用运行次数
来源: 互联网 发布时间: 2014-02-18
获取应用运行次数
这个只有在系统应用才可以用
所以 首先 需要加一个权限:
android.permission.PACKAGEUSAGESTATS
然后 需要把应用放在 System/app 下才能使用
需要在shell里执行命令:
mount -o remount,rw /system (需要root权限才可以使用)
PackageManager manager = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0); List<ComponentName> names = new ArrayList<ComponentName>(); List<Map<String, String>> list = new ArrayList<Map<String, String>>(); for (ResolveInfo info : infos) { ComponentName cn = new ComponentName(info.activityInfo.packageName, info.activityInfo.name); names.add(cn); } IUsageStats mUsageStatsService = IUsageStats.Stub .asInterface(ServiceManager.getService("usagestats")); for (ComponentName name : names) { PkgUsageStats aStats = null; ApplicationInfo info = null; try { aStats = mUsageStatsService.getPkgUsageStats(name); info = manager.getApplicationInfo(name.getPackageName(), PackageManager.GET_META_DATA); } catch (Exception e) { e.printStackTrace(); } if (aStats != null && info != null) { String appName = info.loadLabel(manager).toString(); int count = aStats.launchCount; if (count == 0) { continue; } Map<String, String> map = new HashMap<String, String>(); map.put("appName", appName); map.put("count", count + ""); list.add(map); } }
这个只有在系统应用才可以用
所以 首先 需要加一个权限:
android.permission.PACKAGEUSAGESTATS
然后 需要把应用放在 System/app 下才能使用
需要在shell里执行命令:
mount -o remount,rw /system (需要root权限才可以使用)
[2] 关于省市的多级联动有关问题
来源: 互联网 发布时间: 2014-02-18
关于省市的多级联动问题
写了个测试 使用gson进行数据的解析 代码如下:
String[] array = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z" };
jsonText = "{\"B\":{\"rows\":[{\"id\":2,\"text\":\"北京市\"}]},\"G\":{\"rows\":[{\"id\":1988,\"text\":\"广州市\"},{\"id\":1958,\"text\":\"深圳\"}]},\"Q\":{\"rows\":[{\"id\":1373,\"text\":\"青岛市\"}]},\"T\":{\"rows\":[{\"id\":23,\"text\":\"天津市\"}]}}";
try {
List<City> mCityLst = new ArrayList<ActivityMain.City>();
Gson gson = new Gson();
JSONObject jsonObj = new JSONObject(jsonText);
for (int i = 0; i < array.length; i++) {
String key = array[i];
boolean isHas = jsonObj.has(key);
if (!isHas) {
System.out.println("没有字母:" + key);
continue;
}
String value = jsonObj.getString(key);
System.out.println("当前字母:" + key + "____" + value);
JSONObject jObj = new JSONObject(value);
String mVlaue = jObj.getString("rows");
List<City> cityLst = gson.fromJson(mVlaue,
new TypeToken<List<City>>() {
}.getType());
for (int j = 0; j < cityLst.size(); j++) {
City item = cityLst.get(j);
item.indexFlag = key;
System.out.println("开始累加:" + key);
mCityLst.add(item);
}
}
for (int i = 0; i < mCityLst.size(); i++) {
City city = mCityLst.get(i);
System.out.println("相关信息:" + city.id + "___" + city.text
+ "___" + city.indexFlag);
}
} catch (JSONException e) {
e.printStackTrace();
}
写了个测试 使用gson进行数据的解析 代码如下:
String[] array = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z" };
jsonText = "{\"B\":{\"rows\":[{\"id\":2,\"text\":\"北京市\"}]},\"G\":{\"rows\":[{\"id\":1988,\"text\":\"广州市\"},{\"id\":1958,\"text\":\"深圳\"}]},\"Q\":{\"rows\":[{\"id\":1373,\"text\":\"青岛市\"}]},\"T\":{\"rows\":[{\"id\":23,\"text\":\"天津市\"}]}}";
try {
List<City> mCityLst = new ArrayList<ActivityMain.City>();
Gson gson = new Gson();
JSONObject jsonObj = new JSONObject(jsonText);
for (int i = 0; i < array.length; i++) {
String key = array[i];
boolean isHas = jsonObj.has(key);
if (!isHas) {
System.out.println("没有字母:" + key);
continue;
}
String value = jsonObj.getString(key);
System.out.println("当前字母:" + key + "____" + value);
JSONObject jObj = new JSONObject(value);
String mVlaue = jObj.getString("rows");
List<City> cityLst = gson.fromJson(mVlaue,
new TypeToken<List<City>>() {
}.getType());
for (int j = 0; j < cityLst.size(); j++) {
City item = cityLst.get(j);
item.indexFlag = key;
System.out.println("开始累加:" + key);
mCityLst.add(item);
}
}
for (int i = 0; i < mCityLst.size(); i++) {
City city = mCityLst.get(i);
System.out.println("相关信息:" + city.id + "___" + city.text
+ "___" + city.indexFlag);
}
} catch (JSONException e) {
e.printStackTrace();
}
[3] CCLayer的一部分显示
来源: 互联网 发布时间: 2014-02-18
CCLayer的部分显示
void YourLayer::visit()
{
glEnable(GL_SCISSOR_TEST);
float floatScale = CC_CONTENT_SCALE_FACTOR();
glScissor(x * floatScale,y * floatScale,width * floatScale,height * floatScale);
CCLayer::visit();
glDisable(GL_SCISSOR_TEST);
}
void YourLayer::visit()
{
glEnable(GL_SCISSOR_TEST);
float floatScale = CC_CONTENT_SCALE_FACTOR();
glScissor(x * floatScale,y * floatScale,width * floatScale,height * floatScale);
CCLayer::visit();
glDisable(GL_SCISSOR_TEST);
}
最新技术文章: