本文整理汇总了Java中no.nordicsemi.android.nrftoolbox.dfu.adapter.FileBrowserAppsAdapter类的典型用法代码示例。如果您正苦于以下问题:Java FileBrowserAppsAdapter类的具体用法?Java FileBrowserAppsAdapter怎么用?Java FileBrowserAppsAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileBrowserAppsAdapter类属于no.nordicsemi.android.nrftoolbox.dfu.adapter包,在下文中一共展示了FileBrowserAppsAdapter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openFileChooser
import no.nordicsemi.android.nrftoolbox.dfu.adapter.FileBrowserAppsAdapter; //导入依赖的package包/类
private void openFileChooser() {
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(mFileTypeTmp == DfuService.TYPE_AUTO ? DfuService.MIME_TYPE_ZIP : DfuService.MIME_TYPE_OCTET_STREAM);
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (intent.resolveActivity(getPackageManager()) != null) {
// file browser has been found on the device
startActivityForResult(intent, SELECT_FILE_REQ);
} else {
// there is no any file browser app, let's try to download one
final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null);
final ListView appsList = customView.findViewById(android.R.id.list);
appsList.setAdapter(new FileBrowserAppsAdapter(this));
appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
appsList.setItemChecked(0, true);
new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView)
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.ok, (dialog, which) -> {
final int pos = appsList.getCheckedItemPosition();
if (pos >= 0) {
final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos];
final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
startActivity(storeIntent);
}
}).show();
}
}
示例2: onImportClick
import no.nordicsemi.android.nrftoolbox.dfu.adapter.FileBrowserAppsAdapter; //导入依赖的package包/类
@Override
public void onImportClick() {
// No item has been selected. We must close the spinner manually.
mConfigurationSpinner.close();
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("text/xml");
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (intent.resolveActivity(getPackageManager()) != null) {
// file browser has been found on the device
startActivityForResult(intent, SELECT_FILE_REQ);
} else {
// there is no any file browser app, let's try to download one
final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null);
final ListView appsList = customView.findViewById(android.R.id.list);
appsList.setAdapter(new FileBrowserAppsAdapter(this));
appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
appsList.setItemChecked(0, true);
new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView).setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.yes, (dialog, which) -> {
final int pos = appsList.getCheckedItemPosition();
if (pos >= 0) {
final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos];
final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
startActivity(storeIntent);
}
}).show();
}
}