小编Ali*_*eza的帖子

Android - onStop()将被延迟调用

我发现我的活动onStop()方法将在不到10秒的时间内被调用.我以前从未见过这种行为.

注意: -活动是singleTop,它以Intent.FLAG_ACTIVITY_REORDER_TO_FRONTflag 开头.

注意: -我正在使用Build Tools v23.0.2.

延迟不是之前,方法将立即调用.

android lag activity-lifecycle android-activity

10
推荐指数
2
解决办法
1923
查看次数

检查物料在RecyclerView中是否完全可见

我正在尝试检查某些特定项目是否可见RecyclerView; 但我无法实现这一点.请帮我确定我的物品是否完全可见RecyclerView.

mrecylerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);
        LinearLayout ll = (LinearLayout) recyclerView.findChildViewUnder(dx, dy);
        if (ll != null) {
            TextureVideoView tvv = (TextureVideoView) ll.findViewById(R.id.cropTextureView);
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我想检查tvv视图是否在视图中完全可见mrecyclerView.

android-scroll android-recyclerview

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

Android Studio 3.1 - 什么是'嵌入式Maven存储库'

Android Studio 3.1最近已经发布,它在Gradle > Android Studio路径中有一个设置命名Enable embedded Maven repository,那有什么作用?应该启用还是不启用?

android-studio android-studio-3.1

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

Intent.ACTION_GET_CONTENT 打开最近的文件,这给出了一个错误的 URI

我正在使用Intent.ACTION_GET_CONTENT它打开最近的文件。从最近的文件中选择项目会产生错误的 URI,但从文件管理器中选择相同的文件会提供正确的 URI,可以由我的代码处理。

public static String getRealPathFromURI(Context context, Uri uri) {
    String path;
    if ("content".equals(uri.getScheme())) {
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        cursor.moveToFirst();
        int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
        path = cursor.getString(idx);
        cursor.close();
    } else {
        path = uri.getPath();
    }

    return path;
}
Run Code Online (Sandbox Code Playgroud)

注意:uri.getPath()当我从最近的文件中选择 PDF 时的输出是/document/...但从文件管理器中选择相同的文件时,.../emulated/....

注意:从最近的文件中选择文件时的错误是

无法从 CursorWindow 读取第 0 行、第 -1 行。在访问 Cursor 中的数据之前,确保它已正确初始化。

android android-intent android-contentresolver android-cursor

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

Android 在 API 18 上使用 Intent 选择 PDF

我正在使用以下代码选择使用 .pdf 的 PDF 文件Intent。它在 Android 5.0+ 上完美运行,但 API 18 上没有出现打开 PDF 文件消息的合适应用程序。

public static Intent pickPdf() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("application/pdf");
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    return intent;
}

startActivityForResult(Intent.createChooser(pickPdf(), "Open with"), PICK_PDF);
Run Code Online (Sandbox Code Playgroud)

pdf android android-intent

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

匹配所有数字但以单个字符分割

这是我的字符串:

你好世界,'4567'是我的号码.

如果/g在.NET中支持(全局修饰符),那么获得我想要的东西没有问题,但是现在,我不知道该怎么做,需要你的帮助.我需要匹配所有数字(4567)但分成单个字符.我希望这样:

比赛1:4,比赛2:5,比赛3:6,比赛4:7

谢谢,Alireza

.net c# regex

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

Android Fragments - remove fragment from back stack if already exists

I have some fragments which will be replaced by following method. I think there's something wrong with my code because I want to prevent from adding multiple times a fragment into the back stack. If I click on fragment B twice, all instances will be added to the back stack and pressing back button will be passed through the two created instances.

public void replaceFragment(Fragment fragment, boolean addToBackStack, boolean customAnimation) {
    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    String …
Run Code Online (Sandbox Code Playgroud)

android android-fragments fragment-backstack

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

如何使用 MetaMask API 发送一些自定义令牌?

MetaMask 文档页面上的示例代码似乎仅发送 ETH。我应该如何自定义示例代码来发送一些自定义令牌?

const transactionParameters = {
  nonce: '0x00', // ignored by MetaMask
  gasPrice: '0x09184e72a000', // customizable by user during MetaMask confirmation.
  gas: '0x2710', // customizable by user during MetaMask confirmation.
  to: '0x0000000000000000000000000000000000000000', // Required except during contract publications.
  from: ethereum.selectedAddress, // must match user's active address.
  value: '0x00', // Only required to send ether to the recipient from the initiating external account.
  data:
    '0x7f7465737432000000000000000000000000000000000000000000000000000000600057', // Optional, but used for defining smart contract creation and interaction.
  chainId: '0x3', // Used …
Run Code Online (Sandbox Code Playgroud)

ethereum metamask

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

使用选择器为TabLayout设置tabSelectedTextColor

以下代码可以正常工作,因为我tabSelectedTextColor直接添加了该属性,并且选定的文本颜色将为白色。

<android.support.design.widget.TabLayout
            ...
            app:tabSelectedTextColor="@color/white"
            app:tabTextColor="@color/tab_layout"/>
Run Code Online (Sandbox Code Playgroud)

但是下面的代码不起作用,我也不知道为什么,也许这是一个错误!

<android.support.design.widget.TabLayout
            ...
            app:tabTextColor="@color/tab_layout"/>
Run Code Online (Sandbox Code Playgroud)

@ color / tab_layout

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Selected state defined so it's better to use it -->
    <item android:color="@color/white" android:state_selected="true"/>
    <item android:color="@color/white" android:state_focused="true"/>
    <item android:color="@color/white" android:state_pressed="true"/>
    <item android:color="#CCFFFFFF"/>
</selector>
Run Code Online (Sandbox Code Playgroud)

注意: #CCFFFFFF color有效,这意味着视图可以tabTextColor正确获取属性值,但无法识别该android:state_selected 项目。我测试了所有有理状态,但没有任何效果。

TabLayout.class

从以下代码复制后TabLayout.class,一切都清晰了。您不认为从选择器中选择文本颜色是更好的方法吗?如果是,请报告。

if(a.hasValue(styleable.TabLayout_tabSelectedTextColor)) {
    int selected = a.getColor(styleable.TabLayout_tabSelectedTextColor, 0);
    this.mTabTextColors = createColorStateList(this.mTabTextColors.getDefaultColor(), selected);
}
Run Code Online (Sandbox Code Playgroud)

android android-selector

3
推荐指数
1
解决办法
3069
查看次数

Android - 将录制的H.264主要配置文件视频转换为H.264基线配置文件的最佳解决方案

我发现MediaPlayer无法播放编码的视频,H.264 Main Profile我尝试过ExoPlayer,Vitamio但没有一个能解决我的问题.最后我发现最好的解决方案是将视频转换为H.264 Baseline Profile.FFmpeg它几乎是9MB,对我的项目来说太重了,所以我不喜欢用它来通过命令将视频转换成该配置文件.我的朋友建议在服务器端转换视频,但我们都知道它的性能不佳.我该怎么办?这个问题的最佳解决方案是什么?

android ffmpeg codec vitamio exoplayer

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