小编gio*_*ozh的帖子

模拟活动内的主页按钮行为

我想模拟软Home按钮的行为.我希望当用户点击我的应用程序的特定活动中的后退按钮时,这将进入后台并显示设备主页.我该怎么办(我知道我应该覆盖活动中的onBackPressed())

android background android-activity

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

仅返回将返回一组行的选择的一行

我有一个像这样的表:

create table myTab(
  id integer primary key,
  is_available boolean not null default true
);
Run Code Online (Sandbox Code Playgroud)

我需要执行一个查询,仅返回第一个遇到的设置is_available为 false 的行。

sql postgresql sql-limit

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

具有不同ArrayList类型作为参数的构造方法

我第一次出现这种"奇怪"的情况.我需要为我的类创建两个不同的构造函数:

public OpponentListAdapter(Context c, ArrayList<MyCustomObject> l){}
Run Code Online (Sandbox Code Playgroud)

public OpponentListAdapter(Context c, ArrayList<String> l){}
Run Code Online (Sandbox Code Playgroud)

因为根据ArrayList的泛型类型,我需要执行不同的操作.但我有这个错误:

方法OpponentListAdapter(Context,ArrayList)具有相同的擦除> OpponentListAdapter(Context,ArrayList)作为OpponentListAdapter类型中的另一种方法

怎么了?也许解决方案很简单,但就目前而言,我找不到任何好处!

java generics android arraylist

0
推荐指数
1
解决办法
1467
查看次数

Admob横幅未显示

通过向我的应用添加adMob横幅,我遇到了一个奇怪的问题.这是我第一次使用android studio,所以我跟着教程(唯一不同的是build.gradle文件的编辑).

我一如既往地为布局添加横幅:

<RelativeLayout     xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_cut"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <ListView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/banner" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/banner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/admob_id" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

并将横幅初始化为我的活动:

 AdView mAdView = (AdView) findViewById(R.id.banner);
 AdRequest adRequest = new AdRequest.Builder().build();
 mAdView.loadAd(adRequest);
Run Code Online (Sandbox Code Playgroud)

现在,当我启动我的应用程序时,横幅空间是空的,我得到一些警告,如

W/Ads? Not enough space to show ad. Needs 360x50 dp, but only has 328x479 dp.
Run Code Online (Sandbox Code Playgroud)

但是日志告诉我横幅已正确加载:

I/Ads? Scheduling ad refresh 40000 milliseconds from now.
I/Ads? Ad finished loading.
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

android admob

0
推荐指数
1
解决办法
1723
查看次数

检查安装的 php 版本是否支持 imagick

我有一些使用 imagick 调整存储在服务器上的图片大小的 php 文件,在我更改服务器后,imagick 功能停止工作。事实上,如果我尝试使用脚本来调整图片大小(适用于旧服务器),则不会创建调整大小的图像,也不会显示错误消息。如何检查我的主机是否支持 imagick?

php imagick

0
推荐指数
1
解决办法
2518
查看次数

获取可滚动视图的整个"屏幕截图"

在我的Fragment的布局中,我有一个带有LinearLayout的ScrollView

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <!-- Other views -->

    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

所以我需要创建和分享scrollview的整个内容的图片.我试过的所有解决方案都只截取可见区域的截图,而不是整个scrollview内容.我能怎么做?

android screenshot android-scrollview

0
推荐指数
2
解决办法
2750
查看次数

使用openssl在stdout RSA加密文本上打印

我正在使用这部分代码

char encrypted_text[1024];
RSA_public_encrypt(sizeof(message), message, encrypted_text, rsa, RSA_PKCS1_OAEP_PADDING);
printf("encrypted text: %s\n", encrypted_text);
Run Code Online (Sandbox Code Playgroud)

而optput是这样的:

v0 뷾s E Z N\ 6~ : & / 〜ͯ L d Ǡ E [ h U.vH2F1Qb^) g ,a Ҩ xvU| > ˢ=W ő \ g

有可能消除 符号??

c unix openssl rsa

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

拍照后关闭android相机意图

我有以下简单代码可以拍摄一张照片并返回到呼叫者活动:

Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri uriSavedImage = Uri.fromFile(new File(Environment
    .getExternalStorageDirectory()
    + directory_path
    + "/"
    + Calendar.getInstance().get(Calendar.MILLISECOND)
    + ".jpg"));
camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
startActivityForResult(camera_intent, 1);

MainActivity.this.startActivityForResult(camera_intent, 0);
Run Code Online (Sandbox Code Playgroud)

但是,只有两张照片后,相机意图才会关闭。因此,在我拍摄一张照片后,相机意图仍然有效。在我拍摄另一张照片之后,直到现在,相机意图才被关闭onActivityResult并被调用。

怎么了?

编辑:我尝试将日志消息打印到onActivityResult中,并且我注意到onActivityResult被调用了两次,但是仅在第二张图片之后(并且在相机意图关闭之后)

android android-intent android-camera

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