我在Google和SO上搜索过但找不到我的答案.
这是我第一次使用gradle系统,现在我正在生成一个已签名的APK上传到Google Play(Project是从eclipse导入的).
现在我已经阅读了这里的部分http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Building-and-Tasks你应该添加signingConfigs
到你的build.gradle
我添加了这些行,现在我看到你需要运行./gradlew assembleRelease
但在我的cmd中运行它返回'gradle'不被识别为内部或外部命令,可操作程序或批处理文件.我也尝试右键单击build.gradle并运行它,说它是成功的但是一旦我在build/apk文件夹中查看了一个名为app-debug-unaligned.apk
那么如何使用Gradle系统生成签名的apk?
我正在尝试将yyyy-MM-dd'T'HH:mm:ss.SSSz格式的日期格式化为yyyy-mm-dd HH:mm:ss,这应该很容易,但我不能让它工作.
必须解析的日期格式为:2012-10-01T09:45:00.000 + 02:00
现在我使用这个简单的日期格式化程序来格式化它:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz", Locale.FRANCE);
Run Code Online (Sandbox Code Playgroud)
但是这给出了类似于2012-10-01T09的输出:45:00.000UTC + 00:00.
我也尝试使用"yyyy-MM-dd'T'HH:mm:ss.SSSZ"作为模式和"yyyy-MM-ddHH:mm:ss".后者以2012-10-01T09:45:00的形式返回日期,但尚未结束.
我认为将T分离出来会有点乱,并且无缘无故地创造开销,那么格式化这些日期的正确方法是什么?
为了说明我想将2012-10-01T09:45:00.000 + 02:00转换成2012-10-01 09:45:00
干杯!
如何在android中更改HttpPost的内容类型?
对于请求,我需要将内容类型设置为application/x-www-form-urlencoded
所以我得到了这段代码:
httpclient=new DefaultHttpClient();
httppost= new HttpPost(url);
StringEntity se = new StringEntity("");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"));
httppost.setEntity(se);
Run Code Online (Sandbox Code Playgroud)
但这并没有成功,我无法在任何地方找到解决方案.
干杯
我在我的应用程序中定义了一些应用程序产品.我已将apk上传到Google Play,并在Google Play上添加了inapp购买产品.
我的ServiceConnection
定义如下:
ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
connect();
}
};
Run Code Online (Sandbox Code Playgroud)
onServiceConnected
调用该函数,bindService
返回true.
接下来是connect
功能.
public void connect() {
new Thread(new Runnable() {
public void run() {
try {
// Purchase type is "inapp", as required by API v3
Bundle skuDetails = mService.getSkuDetails(3, PACKET, "inapp", querySkus);
}
int response = skuDetails.getInt("RESPONSE_CODE");
Log.e("IAP …
Run Code Online (Sandbox Code Playgroud) 这个问题已被多次询问,但是没有一个答案似乎对我有用.
div的css如下:
#info{
display: none;
position: fixed;
z-index: 500;
height: 50%;
width: 60%;
overflow: auto;
background: rgba(187, 187, 187, .8);
}
Run Code Online (Sandbox Code Playgroud)
我试着使用以下代码:
$("#info").click(function(e){
e.stopPropagation();
});
$(document).click(function(){
$("#info").hide();
});
Run Code Online (Sandbox Code Playgroud)
以及这段代码:
$(document).mouseup(function (e){
var container = $("#info");
if (container.has(e.target).length === 0) {
container.hide();
}
});
Run Code Online (Sandbox Code Playgroud)
然而,每当我点击div它也消失,没有线索为什么,但它确实.
还有什么可能有用吗?
我目前正在使用Javacv,它利用public void onPreviewFrame(byte[] data, Camera camera)
相机功能.
由于相机已被弃用,我一直在研究camera2和MediaProjection.这两个库都使用ImageReader类.
目前我ImageReader
使用以下代码实例化这样的:
ImageReader.newInstance(DISPLAY_WIDTH, DISPLAY_HEIGHT, PixelFormat.RGBA_8888, 2);
并附上OnImageAvailableListener
这样的:
private final ImageReader.OnImageAvailableListener mOnImageAvailableListener
= new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
mBackgroundHandler.post(new processImage(reader.acquireNextImage()));
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用RGBA_8888
Javacv 的格式按照这个帖子:https://github.com/bytedeco/javacv/issues/298但这对我不起作用.
所以我正在考虑使用Render脚本将这些Image转换为NV21(YUV_420_SP)
格式(这是onPreviewFrame
函数中相机的默认输出),因为这对我来说对camera
库有用.
我还阅读了这个和本网站的帖子进行转换,但这些对我不起作用,我担心它们会太慢.此外,我对C的了解非常有限.基本上看起来我想要https://developer.android.com/reference/android/renderscript/ScriptIntrinsicYuvToRGB.html的反向操作
那么你怎么能从一个Image
匹配onPreviewFrame
函数输出的字节数组,即NV21(YUV_420_SP)
格式?最好使用Renderscript,因为它更快.
我尝试过使用ImageFormat.YUV_420_888 …
camera android image-processing renderscript android-camera2
我现在一直在日夜搜索一个适合我的Android应用程序的OAuth2库.
我遇到了很多,包括apache amber(正式leeloo)和android开发人员指定的一个(http://developer.android.com/training/id-auth/authenticate.html)似乎已经被欺骗了.
然而,它们都没有工作,甚至没有合并我的项目错误(即在罐子里丢失方法).
因此,我的问题是,如果有任何适当的OAuth2库可以用于Android.我只需要一个库,它允许我检索一个身份验证代码,然后是令牌调用,它将允许自动调整请求.
任何有趣项目(git或w/e)的链接都是最受欢迎的.
我需要获取位图的宽度和高度,但使用它会产生内存不足异常:
Resources res=getResources();
Bitmap mBitmap = BitmapFactory.decodeResource(res, R.drawable.pic);
BitmapDrawable bDrawable = new BitmapDrawable(res, mBitmap);
//get the size of the image and the screen
int bitmapWidth = bDrawable.getIntrinsicWidth();
int bitmapHeight = bDrawable.getIntrinsicHeight();
Run Code Online (Sandbox Code Playgroud)
我在问题上阅读解决方案获取位图宽度和高度而不加载到内存但这里的inputStream是什么?
我在我的应用程序中使用gradle包含了一个项目:
compile group: 'org.bytedeco', name: 'javacv', version: '0.11'
Run Code Online (Sandbox Code Playgroud)
哪个建好了.但每当我在启用proguard的情况下运行应用程序时,它显然会@Platform
从包含的jar中删除注释.
我尝试使用基于http://proguard.sourceforge.net/manual/examples.html#annotations的以下内容
-keepattributes *Annotation*
-keep @org.bytedeco.javacpp.annotation interface * {
*;
}
Run Code Online (Sandbox Code Playgroud)
我还根据http://proguard.sourceforge.net/manual/troubleshooting.html#notkept尝试了以下内容
-keep @interface *
Run Code Online (Sandbox Code Playgroud)
但这也不起作用.还有什么可以阻止proguard删除这些注释?我正在考虑使用-injars
或者-libraryjars
我相信gradle为你处理.
所以解决方案如下:
我在我的proguard规则中包含以下内容:
# JavaCV
-keep @org.bytedeco.javacpp.annotation interface * {
*;
}
-keep @org.bytedeco.javacpp.annotation.Platform public class *
-keepclasseswithmembernames class * {
@org.bytedeco.* <fields>;
}
-keepclasseswithmembernames class * {
@org.bytedeco.* <methods>;
}
-keepattributes EnclosingMethod
-keep @interface org.bytedeco.javacpp.annotation.*,javax.inject.*
-keepattributes *Annotation*, Exceptions, Signature, Deprecated, SourceFile, SourceDir, LineNumberTable, LocalVariableTable, LocalVariableTypeTable, …
Run Code Online (Sandbox Code Playgroud) 我有一个ListView
在ScrollView
显示意见,我想做到以下几点:
当用户向下滑动时,首先ScrollView
应该完全向下滚动,因为列表位于底部.一旦完全关闭,Listiew
应该开始滚动.
类似地,当用户向上滚动时,首先ListView
(在此处反转的顺序!)应该在ScrollView
开始滚动之前向上滚动.
到目前为止,我已经做了以下事情:
listView.setOnTouchListener(new View.OnTouchListener() {
// Setting on Touch Listener for handling the touch inside ScrollView
@Override
public boolean onTouch(View v, MotionEvent event) {
// If going up but the list is already at up, return false indicating we did not consume it.
if(event.getAction() == MotionEvent.ACTION_UP) {
if (listView.getChildCount() == 0 && listView.getChildAt(0).getTop() == 0) {
Log.e("Listview", "At top!");
return false;
}
}
// Similar behaviour …
Run Code Online (Sandbox Code Playgroud)