<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
mContext.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
static public @Nullable
Uri cacheUri(Uri uri, Context context) throws IOException {
InputStream inputStream = context.getContentResolver().openInputStream(uri);
if (inputStream != null) {
java.io.File outputDir = Objects.requireNonNull(context).getCacheDir(); // context being the Activity pointer
java.io.File outputFile = java.io.File.createTempFile("spool_job_", "",outputDir);
BufferedInputStream input = new BufferedInputStream(inputStream);
BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(outputFile));
// read and write into the cache directory
byte[] bArr = new byte[8192];
while (true) {
int read = input.read(bArr);
if (read < 0) {
break;
} else {
output.write(bArr, 0, read);
}
}
// close the streams
input.close();
output.close();
return Uri.fromFile(outputFile);
}
return null;
}
<SwitchPreferenceCompat
app:defaultValue="false"
android:persistent="false"
app:key="openLink"
app:title="Ссылки на чек"
app:summaryOn="обрабатываются этим приложением"
app:summaryOff="действие по умолчанию в Android">
</SwitchPreferenceCompat>
<Preference
android:key="pref_static_field_key"
android:selectable="false"
android:persistent="false"
android:summary="Чтобы вместо перехода на сайт налоговой, происходила обработка приложением, потребуется подтвердить выбор в системных настройках.\nОткрывать по умолчанию - Добавить ссылку - Поставить галочку"/>
@RequiresApi(api = Build.VERSION_CODES.S)
private boolean checkLinkAssociation() {
Context context = requireActivity();
DomainVerificationManager manager;
manager = context.getSystemService(DomainVerificationManager.class);
DomainVerificationUserState userState;
try {
userState = manager.getDomainVerificationUserState(context.getPackageName());
} catch (PackageManager.NameNotFoundException e) {
return false;
}
Map<String, Integer> hostToStateMap = userState.getHostToStateMap();
for (String key : hostToStateMap.keySet()) {
Integer stateValue = hostToStateMap.get(key);
if (stateValue != null && stateValue != DomainVerificationUserState.DOMAIN_STATE_VERIFIED && stateValue != DomainVerificationUserState.DOMAIN_STATE_SELECTED) {
return false;
}
}
return true;
}
prefOpenLink = findPreference( "openLink");
if (prefOpenLink != null) {
final Intent i = new Intent();
i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.setData(Uri.parse("package:" + requireActivity().getPackageName()));
prefOpenLink.setIntent(i);
}
@Override
public void onResume() {
super.onResume();
if (prefOpenLink != null) {
boolean status = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
status = checkLinkAssociation();
}
prefOpenLink.setChecked(status);
}
}
WebView webView = findViewById(R.id.myBrowser);
webView.loadUrl("file:///android_asset/index.html");
<receiver>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<receiver
android:name=".tv.RunOnInstallReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.media.tv.action.INITIALIZE_PROGRAMS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service
android:name=".tv.AddMenuService"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
android:focusable="true"
android:nextFocusXX
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<shape android:shape="rectangle" >
<solid android:color="@color/colorPrimary" />
<stroke
android:width="3dp"
android:color="@color/border_blue_btn" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<solid android:color="@color/colorPrimary" />
</shape>
</item>
</selector>
Придется освоить подобное в дравебле