小编hos*_*ini的帖子

分享图片在viber和facebook中不起作用

我使用下面的代码来共享图像但不幸的是它只适用于Line,而不适用于FacebookViber

码:

 Intent share = new Intent(android.content.Intent.ACTION_SEND);
 share.setType("image/png");
 share.putExtra(Intent.EXTRA_STREAM, Uri.parse(G.DIR_APP + "/sample_image.png"));
 startActivity(Intent.createChooser(share, "Share image"));
Run Code Online (Sandbox Code Playgroud)

android facebook android-intent viber

18
推荐指数
1
解决办法
1420
查看次数

如何用Javascript更改EditText内容?

我们有一个HTML按钮.当用户单击它时,我的特定值EditText应该更改,但它不会.

码:

class ActivityTest extends Activity {

    TextView textView1;

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);

        WebView webView = (WebView) findViewById(R.id.webView);
        webView.loadUrl("file:///android_res/raw/htmlimages.html");
        webView.addJavascriptInterface(new MyTest(), "Scripts");
        webView.getSettings().setJavaScriptEnabled(true);
        textView1 = (TextView) findViewById(R.id.textView1);
    }


    public class MyTest {

        void setText(String string) 
        {
            textView1.setText(string);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

html javascript android android-edittext

12
推荐指数
1
解决办法
984
查看次数

如何解决“违反Android广告ID政策的使用和开发者分发协议第4.8节”

今天,我收到了来自Google的电子邮件:

嗨,...的开发人员

经过审查,由于违反政策,appName com.app.package已从Google Play中删除。在您提交合规更新之前,该应用将对用户不可用。

问题:违反Android广告ID政策和《开发者分发协议》第4.8条的使用

Google Play要求开发人员在应用程序请求或处理敏感的用户或设备信息时提供有效的隐私权政策。我们已经确定您的应用收集并传输了Android广告标识符,这符合隐私政策的要求。如果您的应用收集了Android广告ID,则必须在Play控制台中的指定字段以及应用内部提供有效的隐私权政策。

后续步骤:提交您的应用进行其他审核

仔细阅读Android广告ID和用户数据的使用政策以及开发者分发协议,并对您的应用进行适当的更改。如果您决定收集敏感的用户信息,请务必遵守上述政策,并在应用的商品详情页面和应用内包含指向有效隐私权政策的链接。确保您的应用符合所有其他开发者计划政策。如果还有其他违反政策的行为,则可能会执行其他强制措施。登录您的Play控制台,然后将更新提交给您的应用。或者,您可以通过删除对敏感权限或用户数据的任何请求来选择退出此要求。

如果获得批准,您的应用将再次可用,所有安装,评级和评论均保持不变。

如果您已查看政策,并认为此删除操作有误,请与我们的政策支持小组联系。我的一位同事将在2个工作日内与您联系。

感谢您帮助我们为Google Play用户提供清晰透明的体验。

问候,

贾斯汀

即使我没有在应用程序中显示广告,我也不会收集或传输Android广告。
我已经将这些依赖项添加到应用程序级别gradle:

// Firebase Core
implementation 'com.google.firebase:firebase-core:16.0.7'

// Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'

// Firebase Cloud Messaging
implementation 'com.google.firebase:firebase-messaging:17.3.4'

// Google Play services
implementation 'com.google.android.gms:play-services-auth:16.0.1'
Run Code Online (Sandbox Code Playgroud)

如果必须在我的应用程序中添加隐私策略,如何创建隐私策略?

编辑: 我添加了隐私策略,几个小时后,我的应用再次发布。为了创建隐私政策,我使用了此模板

android google-play privacy-policy

11
推荐指数
1
解决办法
4118
查看次数

无法解决:添加谷歌架构组件依赖项时支持片段错误

我想在我的应用程序中使用Google架构组件,但在将android Studio更新为3.1.1时,我将android.arch.lifecycle:extensions:1.1.1依赖项添加到app.gradle文件中,它将显示Failed to resolve: support-fragment
我的gradle版本为4.4

在此输入图像描述

这是app gardle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "ir.apptori.myapplication"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    implementation "android.arch.lifecycle:extensions:1.1.1"
}
Run Code Online (Sandbox Code Playgroud)

请指导我如何解决它,谢谢

android android-gradle-plugin android-architecture-components

9
推荐指数
1
解决办法
4451
查看次数

如何在自定义视图中获取android默认属性

我创建了一个简单的自定义视图,其中包含a RelativeLayoutEditText:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/edt_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

此外,我添加了一些自定义属性res/values/attrs.xml,我在自定义视图构造函数中检索这些属性,一切正常.

现在,我想EditText在自定义视图中检索默认属性,例如我想android:text在自定义视图中获取属性.

我的自定义视图类(简化):

public class CustomEditText extends RelativeLayout {
    private int panCount;

    public CustomEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs,
            R.styleable.CustomEditText, 0, 0);
        try {
            this.panCount = typedArray.getInt(R.styleable.CustomEditText_panCount, 16);
        } finally {
            typedArray.recycle();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果不重新声明文本属性,我怎么能这样做res/values/attrs.xml呢?

android android-widget custom-view android-custom-view android-attributes

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

按字母顺序对数组列表进行排序(波斯语)

我有波斯语的项目列表,我想按字母顺序对它们进行排序。
据我了解,Java不支持正确按波斯字母排序。

我的代码:

List<String> items = new ArrayList<>();
items.add("??");
items.add("????");
items.add("???");
items.add("????");
items.add("???");

Collections.sort(items);
Run Code Online (Sandbox Code Playgroud)

当我打印此列表时,结果将是:

??
????
???
???
????
Run Code Online (Sandbox Code Playgroud)

但是它必须是这样的:

??
????
????
???
???
Run Code Online (Sandbox Code Playgroud)

这些字母有问题吗????
我该如何解决?

java sorting list

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

ViewPager2默认位置

我正在使用ViewPager2创建幻灯片。例如,幻灯片显示有3个项目,我想在活动打开时显示第二个项目。我使用setCurrentItem(int item, boolean smoothScroll)方法,但是它不起作用,什么也没发生。我该如何实现?

viewPager.adapter = adapter
viewPager.setCurrentItem(1, true)
Run Code Online (Sandbox Code Playgroud)

android android-viewpager2

4
推荐指数
8
解决办法
360
查看次数

CoordinatorLayout和RecyclerView问题

我正在使用CoordinatorLayout和NestedScrollView创建活动,如下所示: 在此处输入图片说明

我的布局结构是这样的:

<android.support.design.widget.CoordinatorLayout          
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activity.MovieDetailActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/imgToolbarImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/backdrop"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

        <android.support.v4.widget.NestedScrollView
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.v7.widget.CardView
                    ... >
                    <ImageView
                       ... />
                </android.support.v7.widget.CardView>

                <TextView
                        ... />

                <TextView
                        ... />

                <ImageView
                        ... />

                <TextView
                    ... />

                <com.aminiam.moviekade.custom_view.ExpandableTextView
                    ... />

                <android.support.v4.view.ViewPager
                   ... />

                <com.aminiam.moviekade.custom_view.DotIndicator
                    ... /> …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview android-coordinatorlayout

2
推荐指数
1
解决办法
619
查看次数

什么是复制(Bitmap.Config.ARGB_8888, true)

在这段代码中:

Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.image1).copy(Bitmap.Config.ARGB_8888, true);
Run Code Online (Sandbox Code Playgroud)

有什么作用copy(Bitmap.Config.ARGB_8888, true)

android copy bitmapfactory

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