设备:模拟器像素 3a - Android 11
代码:
final List<Intent> cameraIntents = new ArrayList<Intent>();
final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final List<ResolveInfo> listCam =
context.getPackageManager().queryIntentActivities(captureIntent, 0);
Run Code Online (Sandbox Code Playgroud)
使用时:
targetSdkVersion 30
compileSdkVersion 30
Run Code Online (Sandbox Code Playgroud)
listCam 大小为 0
当更改为:
compileSdkVersion 29
Run Code Online (Sandbox Code Playgroud)
listCam 大小为 1 - 应该如此。
使用以下代码:
val captureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
baseActivity.startActivity(captureIntent)
Run Code Online (Sandbox Code Playgroud)
工作正常并显示相机应用程序。
知道为什么 queryIntentActivities 不返回相机意图吗?
谢谢!
android android-intent android-camera android-camera-intent android-intent-chooser
我正在尝试使用以下内容创建RecyclerView.Adapter:
abstract class BaseSettingsViewHolder<T>(var viewDataBinding :
ViewDataBinding) : RecyclerView.ViewHolder(viewDataBinding.root) {
abstract fun onBind(data: T, presenter: ISettingsPresenter, position: Int)
}
Run Code Online (Sandbox Code Playgroud)
class SettingsTitleViewHolder(viewDataBinding: ViewDataBinding) : BaseSettingsViewHolder<TitleData>(viewDataBinding) {
override fun onBind(data: TitleData, presenter: ISettingsPresenter, position: Int) {
viewDataBinding.setVariable(BR.titleData, data)
viewDataBinding.setVariable(BR.itemPosition, position)
viewDataBinding.setVariable(BR.settingsPresenter, presenter)
viewDataBinding.executePendingBindings()
}
}
Run Code Online (Sandbox Code Playgroud)
并在尝试声明适配器时:
class SettingsAdapter(var context: Context, var presenter: ISettingsPresenter) : RecyclerView.Adapter<BaseSettingsViewHolder>() {
Run Code Online (Sandbox Code Playgroud)
我得到了"期望类的一个类型参数"编译错误:
RecyclerView.Adapter<BaseSettingsViewHolder>
Run Code Online (Sandbox Code Playgroud)
感谢帮助!
我试图让用户使用以下代码选择一个电子邮件帐户:
Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"},
false, null, null, null, null);
startActivityForResult(intent, 23);
Run Code Online (Sandbox Code Playgroud)
此代码效果很好,但如果用户没有Gmail帐户,但雅虎,Hotmail等.如何通过更改第三个参数显示所有电子邮件帐户:
new String[]{"com.google"}
Run Code Online (Sandbox Code Playgroud)
非常感谢你
我正在使用反射方法freeStorageAndNotify:
Method freeStorageAndNotify = null;
freeStorageAndNotify = service.packageManager.getClass().getMethod(
"freeStorageAndNotify", long.class, IPackageDataObserver.class);
freeStorageAndNotify.invoke(PackageManager.class, maxCache + freeSpace, packageDataObserver);
Run Code Online (Sandbox Code Playgroud)
这会导致InvocationTargetException:
java.lang.SecurityException: Neither user 10199 nor current process has android.permission.CLEAR_APP_CACHE.
Run Code Online (Sandbox Code Playgroud)
一些要点: - 我已经有android.permission.CLEAR_APP_CACHE - 这只发生在android"M"版本中(从开发者网站闪烁预览sdk)
我知道这是一个黑客攻击,谷歌没有为此提供一些官方API,但是有很多清洁应用程序只需点击一下即可清除所有设备缓存,所以如果有人知道如何通过另一种解决方法绕过这个问题我我很高兴看到这一点.
非常感谢你的帮助
我正在尝试从 Crashlytics Beta 迁移到 Firebase App Distribution。CircleCi 在中间。
CircleCi 中的构建失败,并显示以下错误:
- 出了什么问题:任务“:FiverrApp:appDistributionUploadRelease”的执行失败。服务凭证文件不存在。请检查服务凭证路径并重试
这是我在 build.gradle 中配置 serviceCredentialsFile 变量的方法:
release {
buildConfigField "boolean", "FORCE_LOGS", "true"
firebaseAppDistribution {
releaseNotes="Notes\n" + getCommitMessages()
groups="android-testers"
serviceCredentialsFile="/api-project-xxx-yyy.json"
}
}
Run Code Online (Sandbox Code Playgroud)
文件 api-project-xxx-yyy.json 与 build.gradle 文件位于同一文件夹中。我也试过:
serviceCredentialsFile="api-project-xxx-yyy.json"
serviceCredentialsFile='api-project-xxx-yyy.json'
Run Code Online (Sandbox Code Playgroud)
仍然没有运气......如果有人能帮助我,我将不胜感激。
在创建简单的xml设计时,我在项目中面临一个奇怪的问题,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#FF0000"
android:layout_marginLeft="30dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_gravity="left|center_vertical"/>
Run Code Online (Sandbox Code Playgroud)
现在看看差异,这是4.2.2中的视图:

这是2.3.3中的一个:

如果有人可以帮助我,我将不胜感激.谢谢
我正在尝试使用幻灯片进/出动画实现片段事务.我正在开发至少14 sdk所以ObjectAnimator对我来说是唯一的选择(还有其他方法吗?根据我的理解,翻译动画不可用).
守则很简单:
AnimationView.java - 包装类
public class AnimationView extends LinearLayout {
public AnimationView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public float getYFraction() {
return getHeight();
}
public void setYFraction(float yFraction) {
final int height = this.getHeight();
setY((height > 0) ? (yFraction * height) : -9999);
}
}
Run Code Online (Sandbox Code Playgroud)
滑入和滑出xml
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:propertyName="yFraction"
android:valueType="floatType"
android:valueFrom="-1"
android:valueTo="0"
android:duration="600"/>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:propertyName="yFraction"
android:valueType="floatType"
android:valueFrom="0"
android:valueTo="1"
android:duration="600"/>
Run Code Online (Sandbox Code Playgroud)
动画效果很好,你可以看到我使用了自定义属性yFraction.但性能非常糟糕......在某些平板电脑中,我注意到动画期间有一条水平的白线(大约3像素高),在其他智能手机设备中,它只是变慢(不是持续时间慢而是闪烁).
如果我将valueFrom&valueTo设置为适合视图维度,我找到了修复它的方法,但它不是通用的,并且需要0到1才能对所有视图都通用 …
android android-animation android-fragments objectanimator fragmenttransaction
我正在尝试在Android的相机上实现突发模式(目前在ICS上)我在网上搜索试图找到有关此功能的一些文档并遇到几个问题:
需要保存(可能是asynctask)每个捕获的图像值,然后处理它并将其保存在SD卡中
在连续模式下捕获图像时可能会处理堆
到目前为止,这是我在调查此问题时得到的第一印象,有人可以指导我在哪里可以获得更多信息,算法甚至是源代码?
谢谢您的帮助.乌迪
我在创建自己的CustomInfoWindow时遇到问题.在不知道何处和原因的情况下获得异
这是我简单的customInfoWindow类
public class CustomInfoWindow implements InfoWindowAdapter {
private LayoutInflater mInflater;
public CustomInfoWindow(LayoutInflater inflater) {
this.mInflater=inflater;
}
@Override
public View getInfoContents(Marker marker) {
View popup = mInflater.inflate(R.layout.info_window_layout, null);
TextView tv=(TextView)popup.findViewById(R.id.title);
tv.setText(marker.getTitle());
tv=(TextView)popup.findViewById(R.id.address);
tv.setText(marker.getSnippet());
return popup;
}
@Override
public View getInfoWindow(Marker marker) {
View popup = mInflater.inflate(R.layout.info_window_layout, null);
TextView tv=(TextView)popup.findViewById(R.id.title);
tv.setText(marker.getTitle());
tv=(TextView)popup.findViewById(R.id.address);
tv.setText(marker.getSnippet());
return popup;
}
Run Code Online (Sandbox Code Playgroud)
}
我在这里设置它.(主要活动)
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
Statics.LAT_TLV, Statics.LON_TLV), 13));
CustomInfoWindow customInfoWindow = new CustomInfoWindow(getLayoutInflater());
mMap.setInfoWindowAdapter(customInfoWindow);
Run Code Online (Sandbox Code Playgroud)
我没有实现onMarkerClick方法.地图加载标记(约40),但当我点击其中一个标记时,我得到:
01-10 13:15:24.321: E/AndroidRuntime(21162): FATAL EXCEPTION: …Run Code Online (Sandbox Code Playgroud) 我无法在android studio中打开监视器(ddms),发现以下错误:
必须提供Java运行时环境(JRE)或Java开发工具包(JDK)才能运行Monitor.搜索以下位置后未找到Java虚拟机:当前PATH中的C:\ Android-Studio\android-studio\sdk\tools\lib\monitor-x86\jre\bin\javaw.exe javaw.exe
将不胜感激任何建议如何解决这个问题.谢谢
android ×10
android-view ×1
android-xml ×1
caching ×1
camera ×1
circleci ×1
circleci-2.0 ×1
ddms ×1
infoview ×1
kotlin ×1
performance ×1