我的问题很简单.我想知道我的应用程序的最佳做法是什么,以便它可以"防止打瞌睡".随着Android N将在更多情况下应用Doze,这变得更加相关.
在阅读Doze文档时,有一部分提到了网络访问:
在打盹模式下,系统会通过限制应用程序访问网络和CPU密集型服务来尝试节省电池电量.它还可以防止应用程序访问网络并延迟其作业,同步和标准警报.
我相信Buetooth属于网络访问,这是正确的吗?
由于我没有使用Marshmallow(或Android N)设备,并且因为Emulator不允许蓝牙交互,所以我无法在打盹模式下测试我的应用行为.
Doze模式会杀死任何正在进行的蓝牙连接吗?这同样适用于Bluetooth Classic和LE吗?带蓝牙A2DP的耳机怎么样?
我的应用必须保持此连接,否则核心功能将被破坏.
当然,对于这样的情况,存在某种例外情况,即用户需要将设备连接到蓝牙远程设备.
我知道存在一个打盹白名单,但在某些情况下,似乎可能不会让应用程序在API 23以下的设备上运行.
谢谢您的帮助!
android bluetooth android-6.0-marshmallow android-doze android-7.0-nougat
有没有办法只在足够大的屏幕上为活动配置多窗口支持,例如平板电脑?
https://developer.android.com/preview/features/multi-window.html#configuring没有提到这一点.设置android:minimalHeight和android:minimalWidth似乎没有帮助,因为
如果用户以分屏模式移动分隔线以使活动小于指定的最小值,系统会将活动裁剪为用户请求的大小.
使用案例:对于某些活动,在非常小(分割)的屏幕尺寸中运行可能没有意义.在这些情况下,活动不应支持多窗口模式.
我对创建支持多窗口功能的完美设计有疑问(来自API 24).请在下面找到我的一些疑问.
页面的宽度和高度直到Marshmallow(API 23)是固定大小,从Nougat(API 24)宽度和应用程序的高度将根据全屏模式,分屏模式和自由格式模式而改变.如何处理这些宽度和高度相关的问题?
如果在正常模式下,例如4个大图像正在填充我的设备的整个宽度,如果我们将其更改为多窗口模式,则宽度减小意味着那么这4个图像将不适合UI.如何处理这种情况?
我正在使用以下代码在我的应用程序中设置特定语言.语言保存SharedPreferences在应用程序中.它完全可以达到API级别23.由于Android N也SharedPreferences运行良好,它返回正确的语言代码字符串,但它不会更改区域设置(设置手机的默认语言).可能有什么不对?
更新1:当我Log.v("MyLog", config.locale.toString());在res.updateConfiguration(config, dm)它返回正确的语言环境后立即使用,但应用程序的语言没有改变.
更新2:我还提到如果我更改区域设置然后重新启动活动(使用新意图并完成旧版本),它会正确更改语言,甚至在轮换后显示正确的语言.但是当我关闭应用程序并再次打开它时,我会得到默认语言.有点奇怪.
public class ActivityMain extends AppCompatActivity {
//...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set locale
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
String lang = pref.getString(ActivityMain.LANGUAGE_SAVED, "no_language");
if (!lang.equals("no_language")) {
Resources res = context.getResources();
Locale locale = new Locale(lang);
Locale.setDefault(locale);
DisplayMetrics dm = res.getDisplayMetrics();
Configuration config = res.getConfiguration();
if (Build.VERSION.SDK_INT >= 17) {
config.setLocale(locale);
} else {
config.locale = locale;
}
}
res.updateConfiguration(config, …Run Code Online (Sandbox Code Playgroud) 我想从Android N的多窗口模式中删除paddingTop/ marginTop导航视图.就像Gmail一样.如果您看到下面的图像,我说的是正常的填充,其大小等于导航视图开头的状态栏.
所以基本上在多窗口模式下(见下图)我必须在我的应用程序位于屏幕的第二部分时删除该填充.
不幸的是,你可以从新的api 24获得,isInMultiWindowMode()但是不可能知道你的应用程序在屏幕的哪个部分.
android android-statusbar android-navigationview android-7.0-nougat
我正在更改我的应用程序代码以支持Android 7,但在我的NotificationCompat.Builder.setSound(Uri)中传递来自FileProvider的Uri,Notification不播放任何声音,在Android 6中使用Uri.fromFile()正常工作.
mp3文件位于:
/Animeflv/cache/.sounds/
这是我的通知代码:
knf.animeflv.RequestBackground
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_not_r)
.setContentTitle(NotTit)
.setContentText(mess);
...
mBuilder.setVibrate(new long[]{100, 200, 100, 500});
mBuilder.setSound(UtilSound.getSoundUri(not)); //int
Run Code Online (Sandbox Code Playgroud)
这是我的UtilSound.getSoundUri(int)
public static Uri getSoundUri(int not) {
switch (not) {
case 0:
return RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
default:
try {
File file=new File(Environment.getExternalStorageDirectory()+"/Animeflv/cache/.sounds",getSoundsFileName(not));
if (file.exists()) {
file.setReadable(true,false);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.N){
return FileProvider.getUriForFile(context, "knf.animeflv.RequestsBackground",file);
}else {
return Uri.fromFile(file);
}
}else {
Log.d("Sound Uri","Not found");
return getSoundUri(0);
}
}catch (Exception e){
e.printStackTrace();
return getSoundUri(0);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest.xml中:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="knf.animeflv.RequestsBackground"
android:exported="false"
android:grantUriPermissions="true"> …Run Code Online (Sandbox Code Playgroud) java android android-studio android-fileprovider android-7.0-nougat
在棉花糖中,添加了ART的AOT编译器。从Android N起,除了AOT外,还添加了另一个编译器JIT。
什么是AOT编译器特定的作业/功能,什么是JIT编译器的作业/功能?
每当我尝试在android 7.0中创建一个SQLite.Net.SQLiteConnection时,我会得到这个异常,任何想法如何修复它?我正在使用这些nuget pacakges:
<packages>
<package id="ExifLib.PCL" version="1.0.1" targetFramework="monoandroid6" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="monoandroid43" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="monoandroid43" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="monoandroid6" />
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="monoandroid6" />
<package id="SQLite.Net-PCL" version="3.1.1" targetFramework="monoandroid6" />
<package id="SQLiteNetExtensions" version="1.3.0" targetFramework="xamarinios1" />
<package id="sqlite-net-pcl" version="1.2.1" targetFramework="monoandroid70" />
<package id="SQLitePCL.bundle_green" version="0.9.3" targetFramework="monoandroid60" />
<package id="SQLitePCL.plugin.sqlite3.android" version="0.9.3" targetFramework="monoandroid60" />
<package id="SQLitePCL.raw" version="0.9.3" targetFramework="monoandroid60" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.1" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.core" version="1.1.1" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.lib.e_sqlite3.android" version="1.1.1" targetFramework="monoandroid70" />
<package id="SQLitePCLRaw.provider.e_sqlite3.android" version="1.1.1" targetFramework="monoandroid70" />
<package …Run Code Online (Sandbox Code Playgroud) xamarin.android xamarin sqlite-net xamarin.forms android-7.0-nougat
我知道在android nougat中更改文件策略.文件共享到其他应用程序的通缉应用程序通过FileProvider生成uri.uri格式是content://com.example.myapp.fileprovider/myimages/default_image.jpg.
我想知道如何从生成的uri获取filepath FileProvider.getUriForFile().因为我的app需要知道物理文件路径才能保存,加载,读取信息等,这是可能的
[简而言之]
content://com.example.myapp.fileprovider/myimages/default_image.jpgFileProvider.getUriForFile.getContentResolver().openFileDescriptor().但我想知道文件路径.android filepath android-intent android-fileprovider android-7.0-nougat
我一直试图解决这个问题2天,没有运气.
我有一个DialogFragment,我希望有一个透明的窗口背景.
我这样做的方式是覆盖DialogFragment类,OnResume如下所示.
public override void OnResume()
{
base.OnResume();
Dialog.Window.SetBackgroundDrawable(new ColorDrawable(new Color(0, 0, 0, 0)));
}
Run Code Online (Sandbox Code Playgroud)
以下是它正在做的截图:
我也试过使用PNG透明背景,没有运气 Dialog.Window.SetBackgroundDrawableResource(Resource.Drawable.transparent);
此问题仅发生在Android 7.0设备上.运行Android 6 ++的另一部手机和平板电脑正在使用透明度
android ×9
xamarin ×2
android-doze ×1
bluetooth ×1
filepath ×1
java ×1
jit ×1
locale ×1
multi-window ×1
split-screen ×1
sqlite-net ×1