小编Ski*_*ᴉʞS的帖子

java.lang.UnsupportedOperationException:出于安全原因,特权进程中不允许使用WebView

我尝试在我的设备的设置应用程序中选择子集,我看到了这个例外.这是否意味着设置是一个特权进程,无法访问webview?

我尝试从设置中选择HDMI选项,这是异常堆栈:

03-23 08:45:03.301 E/AndroidRuntime( 3299): Caused by: java.lang.UnsupportedOperationException: For security reasons, WebView is not allowed in privileged processes
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:96)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.webkit.WebView.getFactory(WebView.java:2194)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.webkit.WebView.ensureProviderCreated(WebView.java:2189)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.webkit.WebView.setOverScrollMode(WebView.java:2248)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.view.View.<init>(View.java:3588)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.view.View.<init>(View.java:3682)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.view.ViewGroup.<init>(ViewGroup.java:497)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:55)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.webkit.WebView.<init>(WebView.java:544)
03-23 08:45:03.301 E/AndroidRuntime( 3299):     at android.webkit.WebView.<init>(WebView.java:489)
03-23 …
Run Code Online (Sandbox Code Playgroud)

android android-activity

6
推荐指数
2
解决办法
5692
查看次数

RecyclerView添加EmptyView

我正试图在我身上实施EmptyView,RecyclerView Adapter但我没有得到任何结果.

我已经按照本教程和这个提示,但没有人为我工作.

我实施了:

if (viewType == EMPTY_VIEW) {
    v = LayoutInflater.from(parent.getContext()).inflate(R.layout.empty_view, parent, false);
    EmptyViewHolder evh = new EmptyViewHolder(v);
    return evh;
}

v = LayoutInflater.from(parent.getContext()).inflate(R.layout.data_row, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
Run Code Online (Sandbox Code Playgroud)

但它不允许我编译,因为它们是不同的ViewHolder,因为我创建了两个ViewHolder类,但他们extends Recycler.ViewHolder所以我没有得到它...

我正在尝试这样做,因为我有一个SearchView,我想要当列表为空它显示一个EmptyView,我已经得到它以编程方式做它但我更喜欢添加像一个layout因为我不知道那么多怎么样放置TextViews并以Buttons编程方式.

如果我放

return dataList.size() > 0 ? dataList.size() : 1;
Run Code Online (Sandbox Code Playgroud)

它给了我错误,因为索引是0.

我已经调试了viewType并且始终是1,那么它将不会加入if条件......

深入Android我发现了这个:

/** …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

6
推荐指数
1
解决办法
1625
查看次数

带有图像叠加中心和滚动行为的工具栏

我正在创建一个详细的活动,我有一个弯曲的工具栏,在工具栏的中心我有一个圆形的 ImageView,问题是在不同的屏幕上,图像没有居中。

我想要实现的是:

1.- 创建一个带有后退箭头按钮和右侧一个图标的工具栏

我把它定义为:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="@drawable/curve_toolbar_2"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:theme="@style/ThemeOverlay.AppCompat.Dark" />

    <View
        android:id="@+id/view"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:background="@drawable/circle_shape"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/toolbar"
        app:layout_constraintVertical_bias="0.09" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/iv_pew"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_marginEnd="16dp"
        android:layout_marginTop="16dp"
        android:src="@drawable/ic_favorite"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/appCompatImageView"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:background="@drawable/ic_favorite"
        app:layout_constraintBottom_toBottomOf="@+id/view"
        app:layout_constraintEnd_toEndOf="@+id/view"
        app:layout_constraintStart_toStartOf="@+id/view"
        app:layout_constraintTop_toTopOf="@+id/view" />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/tv_example"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Example"
        android:textSize="18sp"
        app:layout_constraintEnd_toEndOf="@+id/view"
        app:layout_constraintStart_toStartOf="@+id/view"
        app:layout_constraintTop_toBottomOf="@+id/view" />

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        app:layout_conokstraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv_example"
        app:layout_constraintVertical_bias="0.13">

        <androidx.cardview.widget.CardView
            android:id="@+id/item_card_view" …
Run Code Online (Sandbox Code Playgroud)

java layout android android-layout kotlin

6
推荐指数
1
解决办法
178
查看次数

如何在Android中制作类似Google Inbox应用的用户界面

Unscrolled Horizo​​ntal RecyclerView

滚动水平RecyclerView

我想在我的APP中制作类似UI的Google Inbox Android应用程序,我知道它一直在使用`RecyclerView`来实现这一点.我有两个问题

1.如何使第一张水平卡片在一些左边填充之后开始绘制,按照层次结构查看器进行循环显示,然后从头到尾显示和滚动,然后如何将第一个项目与给定的左边距对齐?

2.当我们使用这种类型的嵌套回收器视图时,如何维护水平回收器视图的适配器,这样我就不必在每个`onBindViewHolder()`回调中重新创建它以避免每次滚动时的重新通气?

android google-index material-design android-recyclerview

5
推荐指数
0
解决办法
901
查看次数

NSD和WifiP2pManager有什么不同?

在android中制作WiFi程序有多种选择,最常见的方法是使用NSDWifiP2pManager.

这两个选择有什么不同?

android wifi wifimanager wifi-direct

5
推荐指数
1
解决办法
1881
查看次数

Android MediaRecorder崩溃了

更新:

好的,经过几天的测试和调试......我认真工作,但不是我想要的方式.

之前崩溃的原因是因为锁屏期间相机的"重新定向",显然是经常崩溃.

一旦我强迫它使用横向模式,它就有效.但是,我不希望它使用横向模式; 我希望它以纵向模式工作.

代码直接来自Android Studio的示例(Media - > MediaRecorder).样本的代码在横向模式下工作,我无法想象如何使用纵向模式,这样我可以避免重新定位,从而避免崩溃?

onPause中没有任何内容,onResume代码和指向此方法的stacktrace被调用.

轻松再现:

1)使用Android Studio获取MediaRecord示例应用程序2)在清单中,将android:screenOrientation ="landscape">更改为Portrait.3)该应用程序现在不会启动.

我添加了mCamera.setDisplayOrientation(90),同样的问题.

码:

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean prepareVideoRecorder(){

    // BEGIN_INCLUDE (configure_preview)
    mCamera = CameraHelper.getDefaultCameraInstance();

    // We need to make sure that our preview and recording video size are supported by the
    // camera. Query camera to find all the sizes and choose the optimal size given the
    // dimensions of our preview surface.
    Camera.Parameters parameters = mCamera.getParameters();
    List<Camera.Size> mSupportedPreviewSizes = parameters.getSupportedPreviewSizes();
    Camera.Size optimalSize = CameraHelper.getOptimalPreviewSize(mSupportedPreviewSizes,
            mPreview.getWidth(), mPreview.getHeight()); …
Run Code Online (Sandbox Code Playgroud)

java camera android mediarecorder

5
推荐指数
1
解决办法
1118
查看次数

Firebase查询可优化

我有一个Firebase Database看起来像:

我有一个名为的节点 Products

 Products
    |
    |--------prod1_id
    |         | 
    |         |--name : "prod1"
    |          --state: "free"
    |         
    |
    |---------prod2_id
              | 
              |--name : "prod2"
               --price: "not_free"
Run Code Online (Sandbox Code Playgroud)

然后我有用户的节点

Users
     |
     |--------user1_id
     |         | 
     |         |--name : "user1"
     |          --e-mail: "user1@email.com"
     |          
     |
     |---------user2_id
               | 
               |--name : "user2"
                --e-mail: "user2@email.com"
Run Code Online (Sandbox Code Playgroud)

在我的应用程序上,用户可以购买,只有当他/她这样做时,我才会创建一个新的节点PurchasedItems,在那里我存储了UserProduct

Purchased items
             |
             |--------user1_id
             |         | 
             |         |--prod1: "any_value"
             |          --prod2:  "any_value"
             |         
             |
             |---------user2_id
                       | 
                       |--prod1: "any_value"
Run Code Online (Sandbox Code Playgroud)

问题在于我对对象的查询,我这样做:

 products_ref= FirebaseDatabase.getInstance().getReference().child("products");
Run Code Online (Sandbox Code Playgroud)

问题是什么?

登录到应用程序的用户,即使他已经购买了产品,也会显示productNotFree布局,因为在产品上我没有提及用户购买此商品的内容,但我的"TryToPurchase"方法有类似之处,我有一个查询,PurchasedProducts以查看用户是否有此产品或不进行购买. …

android firebase firebase-realtime-database

5
推荐指数
1
解决办法
244
查看次数

将ImageView拖放到容器中以进行验证

为了更好地理解它,请阅读以下内容:

First game :

Skate QuestionMark
Archery QuestionMark
Swim QuestionMark

---------------------------
Water Bow Wheel

If user drags Water to Skate or Archery QuestionMark it will animate to the list (because it is not correct)

If user drags twice incorrect (it will mark the one that is correct from the answer list)

If user still fail in the third try it will drag to the incorrect one and then it will highlight or just change the color doesn't matter to red. …
Run Code Online (Sandbox Code Playgroud)

java android drag-and-drop android-layout kotlin

5
推荐指数
1
解决办法
341
查看次数

SharedPreferences长值

在这里,我正在创建一个SharedPreferences如果我没错,我正在使用此代码:

SharedPreferences sp = getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putLong("ExactTime", minutesToMilliseconds(NumberPicker2.getValue()));
editor.commit();
Run Code Online (Sandbox Code Playgroud)

我正在做的是我得到了value一个NumberPicker,我想保存这个value,一旦用户重启APP甚至重启设备(我不知道是否SharedPreferences......)当用户打开APP时它仍然从中挑选出相同的号码NumberPicker.

我希望在扩展一个类的类中Service使用它.我试过的是:

SharedPreferences sp = this.getSharedPreferences("ExactTime", Context.MODE_PRIVATE);
WifiTimeSearch = sp.getLong("ExactTime", 0);
Run Code Online (Sandbox Code Playgroud)

这里是我丢失的地方......我读过这个"0"表示默认值,但我想使用与我存储的相同的值SharedPreferences...当我尝试使用此Long值时,值为"0".

我做错了什么?

android sharedpreferences

4
推荐指数
1
解决办法
2502
查看次数

地理围栏没有触发

我正试图Geofence在我的APP 上实现,问题是当我在我标记的地方时不会触发.

我做的是我从地方选择器设置Latitude&.Longitude

我得到的价值很好,因为我把它放在google maps正确的位置,因为我已经阅读了许多人从lat/long设置错误值的答案.

我有两个班:GeofenceSingleton.classGeofenceTransitionsIntentService.

GeofenceSingleton.class样子:

public class GeofenceSingleton implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback<Status> {

private GoogleApiClient googleApiClient;
private static GeofenceSingleton _singleInstance;
private static Context appContext;
private static final String ERR_MSG = "Application Context is not set!! " +
        "Please call GeofenceSngleton.init() with proper application context";
private PendingIntent mGeofencePendingIntent;
private static ArrayList<Geofence> mGeofenceList;


private GeofenceSingleton() {
    if (appContext == null)
        throw new IllegalStateException(ERR_MSG);

    this.googleApiClient …
Run Code Online (Sandbox Code Playgroud)

android google-maps geofencing

4
推荐指数
1
解决办法
6144
查看次数