一:对目录下文件的监听
定义
int flags = FileObserver.CREATE | FileObserver.MOVED_TO;
mObserver = new FileObserver(REPORT_DIR.getPath(), flags) {
public void onEvent(int event, String path) {
mHandler.post(new Runnable() { public void run() { scanDirectory(); } });
}
};
开始监听,一般写于onStart()
mObserver.startWatching();
mObserver.startWatching();
停止监听,一般写于onStop()
mObserver.stopWatching();
mObserver.stopWatching();
二:注册ContextMenuInfo为ContextMenu
public void registerForContextMenu (View view)
Since: API Level 1 Registers a context menu to be shown for the given view (multiple views can show the context menu). This method will set the View.OnCreateContextMenuListener on the view to this activity, so onCreateContextMenu(ContextMenu, View, ContextMenuInfo) will be called when it is time to show the context menu.
Parameters
view The view that should show a context menu.
See Also
unregisterForContextMenu(View)
AdapterView.AdapterContextMenuInfo extends
ContextMenu.ContextMenuInfo
注册到Menu中,可以直接从MenuItem中获取Info相关信息进行操作
registerForContextMenu(getListView());
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, SYSTEM_LOG_ID, 0, "System Log");
menu.add(0, CPU_ID, 0, "CPU Info");
menu.add(0, MEMORY_ID, 0, "Memory Info");
menu.add(0, PROCRANK_ID, 0, "Procrank");
}
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (info.position >= mFiles.size()) {
return true;
}
int id = item.getItemId();
switch (id) {
case SYSTEM_LOG_ID: // drop down
case MEMORY_ID: // drop down
case CPU_ID: // drop down
case PROCRANK_ID:
File file = mFiles.get(info.position);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "vnd.android/bugreport");
intent.putExtra("section", ID_MAP.get(id));
startActivity(intent);
return true;
default:
return super.onContextItemSelected(item);
}
}
分享到:
相关推荐
slam cleaner robot android app source code
android studio期末作业AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_...
AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458...
Pro-Android-Web-Apps-Developing-HTML5-JavaScript-CSS-and-Chrome-OS-Web-Apps.pd
Android-apps-android-wikipedia.zip,官方的Android维基百科应用程序!,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
Android--开发--AnderWeb-Android--开发--_packages_apps_Launcher-4458ee4
Android Apps的GUI设计(GUI Design for Android Apps)-英文原版,0积分
Android-amazing-android-apps.zip,用Java编写的惊人的开源Android应用程序。,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
Developing-Android-Apps-course Udacity course by Google see: https://www.udacity.com/course/developing-android-apps--ud853 Lesson 1 - Creating Project Sunshine - Learn how to create and run a simple ...
com-google-android-apps-authenticator2-6004000-64865720-4047d033a11fdda7627bb45f5be525b1.apk.1
Apps using the library: Gourmet (http://thegourmet.app) Playstore PS: Please let me know if you are using this library in your app to list here. email: ark.akshaykale@gmail.com) Install Add ...
This library is a download manager android/java library which developers can use in their apps and allow you to download files in parallel mechanism in some chunks and notify developers about tasks ...
Android Payments Support both Google Play and Amazon Kindle Fire in-app purchase payments with a single API Handy for small apps with in-app purchase (IAP) items that need both Google Play store and ...
logback-android v1.1.1-6 Overview logback-android brings the power of logback to Android. This library provides a highly configurable logging framework for Android apps, supporting multiple log ...
Version 4.0.0 now requires Android target SDK 26 and Gradle 3 plugin in order to support ExoPlayer 2.9.0. Google is dropping support for apps using target SDKs older than 26 as of Oc
Android-android-instant-apps.zip,迁移:,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
We specialize in the designing and coding of custom UI for Mobile Apps and Websites.Looking for developers for your project? The Android mockup available here. Requirements Android 4.0 ...
Latest animation ideas I developed to make apps more attractive. Why having such a repository? Through all projects I've been through, no matter how reliable the app you are developing can be, there ...