[android-developers] Re: setPreviewCallbackWithBuffer issue
Did you get any solution on that? On Saturday, April 9, 2011 9:22:42 AM UTC+2, chen ji wrote: Hi All, I use Android 2.3 on NeuseOne. Now, I use setPreviewCallbackWithBuffer to get preview callback and it works well. But if I call takepicture, it will halt and I can not get jpegcallback. But if I use setPreviewCallback, all things works well. But as you know, its memroy is inefficient. I just want to know what is the special thing before I call takepicture when i use setPreviewCallbackWithBuffer . BTW, my set preview call back code is just below: Size size = p.getPreviewSize(); callbackBuffer1 = new byte[ size.width * size.height * 3 / 2 + 1]; callbackBuffer2 = new byte[size.width * size.height * 3 / 2 + 1]; ; mCamera.setPreviewCallbackWithBuffer(mPreviewCallback); // if I use mCamera.setPreviewCallback(mPreviewCallback); it works well mCamera.addCallbackBuffer(callbackBuffer1); mCamera.addCallbackBuffer(callbackBuffer2); Thanks, Ji -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups Android Developers group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: can not set preview buffer format to nv21 on nexus 4
I think you got a bit confused. Use NV21 for setPreviewFormat (which is YUV420sp), and Jpeg for setPictureFormat. If you want to process RGB pixels on the onPictureTaken callback which is when a picture is taken, then use the next line: public void onPictureTaken(final byte[] data, final Camera camera) { Bitmap bitmap = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length); } If instead you want to process the preview frames, then you need to find a converter for YUV42sp to RGB, there are many around if you google a bit. On Saturday, March 16, 2013 5:45:08 AM UTC+1, Qianqian Fang wrote: Based on the help for getSupportedPreviewFormats [1], NV21 should be always supported. However, when I run camParam = mCamera.getParameters(); camParam.setPictureFormat(ImageFormat.NV21); mCamera.setParameters(camParam); on my nexus 4, I get an error setParameters failed. The only way to get through is to use ImageFormat.JPEG, which is the default. is nv21 supported on nexus 4? if I can not set format to nv21, how can I read the RGB values per pixel with an JPEG preview buffer format? thanks Qianqian [1] http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupportedPreviewFormats() -- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups Android Developers group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[android-developers] Unexpected animation when changing Layout Margins on Jelly Bean
Since I upgraded to Jelly Bean 4.1.1 I have an unexpected sliding animation whenever changing the margins of any RelativeLayout programmatically. This happens if for example I change margins from (10, 10, 200, 200) to (20, 20, 220, 220), so meaning that because of the margins the layout will actually change position. The model I used for development is a Samsung Galaxy SIII. Is this something new that Google implemented on this version? or something specific from Samsung? I can't find on the API any reference on this. Anyone knows how to override this sliding animation which I haven't in fact set at all? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] NDK, encoding to JPEG
With NDK, how to encode an int[] array of RGBA pixels into JPEG file? I read about the libjpeg, etc. but I cannot find any out of be box solution. does the NDK have any api to encode JPEG files? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Problem with OpenGL ES and shaders
Hello I am learning now OpenGL ES and the use of shaders. I have written a test class that should only paint the application icon into the screen. So far no luck. Can anyone see what I am doing wrong or maybe point me to the right direction? public class GLTester { final int FLOAT_SIZE_BYTES = 4; int glProgramHandle = 0; int glVertexShaderHandle = 0; int glFragmentShaderHandle = 0; int glPositionHandle = 0; int glTextCoordHandle = 0; int glTextureHandle = 0; int frameTextureHandle = 0; FloatBuffer vertexBuffer = null; final float squareVertices[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f }; FloatBuffer textureBuffer = null; final float textureVertices[] = { -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f }; final String vertexShaderCode= attribute vec4 a_position; attribute vec2 a_texcoord; varying vec2 v_texcoord; void main() {v_texcoord = a_texcoord; gl_Position = a_position;}; final String fragmentShaderCode = precision mediump float; varying vec2 v_texcoord; uniform sampler2D u_texture; void main() {gl_FragColor = texture2D(u_texture, v_texcoord.st);}; Bitmap bitmap = null; void test(final Context context) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inScaled = false; bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon, options); setupGLES(); createProgram(); setupTexture(); draw(); } void setupGLES() { GLES20.glEnable(GLES20.GL_TEXTURE_2D); GLES20.glEnable(GLES20.GL_CULL_FACE); GLES20.glCullFace(GLES20.GL_BACK); GLES20.glDisable(GLES20.GL_DEPTH_TEST); GLES20.glViewport(0, 0, 400, 800); GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } void createProgram() { glProgramHandle = GLES20.glCreateProgram(); glVertexShaderHandle = setupShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode); glFragmentShaderHandle = setupShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); GLES20.glLinkProgram(glProgramHandle); glPositionHandle = GLES20.glGetAttribLocation(glProgramHandle, a_position); glTextCoordHandle = GLES20.glGetAttribLocation(glProgramHandle, a_texcoord); glTextureHandle = GLES20.glGetUniformLocation(glProgramHandle, u_texture); vertexBuffer = ByteBuffer.allocateDirect(squareVertices.length * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer(); vertexBuffer.put(squareVertices).position(0); textureBuffer = ByteBuffer.allocateDirect(textureVertices.length * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer(); textureBuffer.put(textureVertices).position(0); } int setupShader(final int type, final String code) { int shaderHandle = GLES20.glCreateShader(type); GLES20.glShaderSource(shaderHandle, code); GLES20.glCompileShader(shaderHandle); GLES20.glAttachShader(glProgramHandle, shaderHandle); return shaderHandle; } void setupTexture() { int texture[] = new int[1]; GLES20.glGenTextures(1, texture, 0); frameTextureHandle = texture[0]; texture = null; GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GL10.GL_TEXTURE_2D, frameTextureHandle); GLES20.glUniform1i(glTextureHandle, 0); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); } void draw() { GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); glUseProgram(glProgramHandle); vertexBuffer.position(0); GLES20.glVertexAttribPointer(glPositionHandle, 3, GLES20.GL_FLOAT, false, 0, vertexBuffer); GLES20.glEnableVertexAttribArray(glPositionHandle); textureBuffer.position(0); GLES20.glEnableVertexAttribArray(glTextCoordHandle); GLES20.glVertexAttribPointer(glTextCoordHandle, 2, GLES20.GL_FLOAT, false, 0, textureBuffer); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, frameTextureHandle); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0); GLES20.glUniform1i(glTextureHandle, 0); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, squareVertices.length / 3); GLES20.glDisableVertexAttribArray(glPositionHandle); GLES20.glDisableVertexAttribArray(glTextCoordHandle); GLES20.glDisableVertexAttribArray(glTextureHandle); } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Android test with OpenGL ES Shaders
Hello I am learning now OpenGL ES and the use of shaders. I have written a test class that should only paint the application icon into the screen. So far no luck. Can anyone see what I am doing wrong or maybe point me to the right direction? public class GLTester { final int FLOAT_SIZE_BYTES = 4; int glProgramHandle = 0; int glVertexShaderHandle = 0; int glFragmentShaderHandle = 0; int glPositionHandle = 0; int glTextCoordHandle = 0; int glTextureHandle = 0; int frameTextureHandle = 0; FloatBuffer vertexBuffer = null; final float squareVertices[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f }; FloatBuffer textureBuffer= null; final float textureVertices[] = { -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f }; final String vertexShaderCode= attribute vec4 a_position; attribute vec2 a_texcoord; varying vec2 v_texcoord; void main() {v_texcoord = a_texcoord; gl_Position = a_position;}; final String fragmentShaderCode = precision mediump float; varying vec2 v_texcoord; uniform sampler2D u_texture; void main() {gl_FragColor = texture2D(u_texture, v_texcoord.st);}; Bitmap bitmap = null; void test(final Context context) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inScaled = false; bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon, options); setupGLES(); createProgram(); setupTexture(); draw(); } void setupGLES() { GLES20.glEnable(GLES20.GL_TEXTURE_2D); GLES20.glEnable(GLES20.GL_CULL_FACE); GLES20.glCullFace(GLES20.GL_BACK); GLES20.glDisable(GLES20.GL_DEPTH_TEST); GLES20.glViewport(0, 0, 400, 800); GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } void createProgram() { glProgramHandle = GLES20.glCreateProgram(); glVertexShaderHandle = setupShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode); glFragmentShaderHandle = setupShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); GLES20.glLinkProgram(glProgramHandle); glPositionHandle = GLES20.glGetAttribLocation(glProgramHandle, a_position); glTextCoordHandle = GLES20.glGetAttribLocation(glProgramHandle, a_texcoord); glTextureHandle = GLES20.glGetUniformLocation(glProgramHandle, u_texture); vertexBuffer = ByteBuffer.allocateDirect(squareVertices.length * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer(); vertexBuffer.put(squareVertices).position(0); textureBuffer = ByteBuffer.allocateDirect(textureVertices.length * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer(); textureBuffer.put(textureVertices).position(0); } int setupShader(final int type, final String code) { int shaderHandle = GLES20.glCreateShader(type); GLES20.glShaderSource(shaderHandle, shaderCode); GLES20.glCompileShader(shaderHandle); GLES20.glAttachShader(glProgramHandle, shaderHandle); return shaderHandle; } void setupTexture() { int texture[] = new int[1]; GLES20.glGenTextures(1, texture, 0); frameTextureHandle = texture[0]; texture = null; GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GL10.GL_TEXTURE_2D, frameTextureHandle); GLES20.glUniform1i(glTextureHandle, 0); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); } void draw() { GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); glUseProgram(glProgramHandle); vertexBuffer.position(0); GLES20.glVertexAttribPointer(glPositionHandle, 3, GLES20.GL_FLOAT, false, 0, vertexBuffer); GLES20.glEnableVertexAttribArray(glPositionHandle); textureBuffer.position(0); GLES20.glEnableVertexAttribArray(glTextCoordHandle); GLES20.glVertexAttribPointer(glTextCoordHandle, 2, GLES20.GL_FLOAT, false, 0, textureBuffer); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, frameTextureHandle); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0); GLES20.glUniform1i(glTextureHandle,
[android-developers] CVPixelBufferGetBaseAddressOfPlane in Android
Is there an equivalent in Java/Android of the next iOS function? CVPixelBufferGetBaseAddressOfPlane Description: Returns the base address of the plane at the specified plane index. void * CVPixelBufferGetBaseAddressOfPlane (CVPixelBufferRef pixelBuffer, size_t planeIndex); pixelBuffer: The pixel buffer containing the plane whose base address you want to obtain. planeIndex: The index of the plane. Return Value: The base address of the plane, or NULL for nonplanar pixel buffers. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] LVL and Developer Transfer Account
I recently transferred my developer account into a new one. I took ahead of the change and already had prepared new app builds using the new account Public Key for LVL. I assumed that once the users who already purchased the app would install the update everything would be fine. But already got reports of Invalid License received. Does any one know if purchased applications will still keep on checking against the old key? I thought that once they get the new build update which holds the new developer public key, then the license would still be valid for whoever bought the app with the old account developer key. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Android Push c2dm without a server
Is there a way to implement a device 2 device notification system, by using the c2dm api, but without a third party server for the registration_id? I cannot see how a device can know about the existence of another device, or send directly a notification without implementing a third party server. But by required such server, in increases app maintenance, and of course to make sure the server is alive during all the time you wish to keep the app in the android market. Is there any other API which would allow at least a single ping from device to device? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: New developer agreement
this actually ain't true, is still 15 minutes. The 48 hours has been there since day 1. It only means if that the user contacts you complaining that he wants a refund, he has 48 hours to do it so. But through google checkout he will still have the usual 15 minutes gap. On 19 nov, 14:05, Kostya Vasilyev kmans...@gmail.com wrote: This is a great day for Titanium Backup users :) 19.11.2011 8:54, Nikolay Elenkov пишет: Products that cannot be previewed by the buyer (such as applications): You authorize Google to give the buyer a full refund of the Product price if the buyer requests the refund within 48 hours after purchase. -- Kostya Vasilyev -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: New developer agreement
as I said, the 48hours is there since day one, this has not changed even when the gap was reduced to 15 minutes. Is the type gap for refunds asked directly to the developer or by complain to google. The new agreement is just and update for new content. On Nov 19, 2:31 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Nov 19, 2011 at 8:19 AM, Sanchiski sanchi...@gmail.com wrote: this actually ain't true, is still 15 minutes. The 48 hours has been there since day 1. It only means if that the user contacts you complaining that he wants a refund, he has 48 hours to do it so. But through google checkout he will still have the usual 15 minutes gap. I have a ChangeDetection.com profile set up for this document: http://www.changedetection.com/log/android/developer-distribution-agr... Mostly, the most recent change seems to clarify language from back when the Android Market was just for apps and now is for other types of content as well. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.6 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Prolblem with special key numbers and ACTION_CALL
i found a problem which I can't find solution, maybe someone has seen this before? I use this to perform a call, now if the call is a special number such as *111#, the character # is not sent to the activity, resulting in a call to *111 without the # character. Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(tel: + phoneNumber)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); Anyone understand what happens? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Prolblem with special key numbers and ACTION_CALL
Already found the answer, but in case it might be useful to other people here goes the answer: It is required to enconde the number as Uri.enconde(phonenumber), look next Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(tel: + Uri.encode(phoneNumber))); -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Bluetooth headset
How can be detected if a bluetooth is currently connected? I already used the intent BluetoothDevice.ACTION_ACL_CONNECTED, but this one is sent at connection time, also i tried to check with isBluetoothA2dpOn but doesn't work either. I itarated through al the bluetooh devices and even if the bluetooh is disconnected it returns that are bonded. So is there an api that shows if any bluetooth device is currently in connection state? thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Detect Google Voice
Hi everyone. Is there a way to detect if an outgoing call was performed by Google Voice? in other words, how is it possible to differentiate when a call is done by key\touchpad or via voice? thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Detect Google Voice
i am improving my call confirm program, and I need to find a way to allow calls done through google voice without any popup. On Jul 22, 6:22 pm, saman norallahy samannorall...@gmail.com wrote: why On Fri, Jul 22, 2011 at 7:36 PM, Sanchiski sanchi...@gmail.com wrote: Hi everyone. Is there a way to detect if an outgoing call was performed by Google Voice? in other words, how is it possible to differentiate when a call is done by key\touchpad or via voice? thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Getting contact name by phone number
Hello everyone, I am trying to retrieve the contact name given a contact phone number. I made a function that should work in all API versions, by I can't make it work in 1.6 and I can't see the problem, maybe someone can sport it? Notice I replace it the API constants for strings so I don't have deprecated warning problems. public void getContactName(final String phoneNumber) { Uri uri; String[] projection; if (Build.VERSION.SDK_INT = 5) { uri = Uri.withAppendedPath(Uri.parse(content:// com.android.contacts), phone_lookup); projection = new String[] { display_name }; } else { uri = Uri.parse(content://contacts/phones/filter); projection = new String[] { name }; } uri = Uri.withAppendedPath(uri, Uri.encode(phoneNumber)); Cursor cursor = this.getContentResolver().query(uri, projection, null, null, null); String contactName = ; if (cursor.moveToFirst()) { contactName = cursor.getString(0); } cursor.close(); cursor = null; return contactName; } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Getting a contact name given its phone number
Hello everyone, I am trying to retrieve contact names given the contact phone number. I made a function that should work in all API versions, by I can't make it work in 1.6 and I can't see the problem, maybe someone can spot it? Notice that I've replaced it the API constants for strings so I don't have deprecated warning problems. public String getContactName(final String phoneNumber) { Uri uri; String[] projection; if (Build.VERSION.SDK_INT = 5) { uri = Uri.parse(content://com.android.contacts/phone_lookup); projection = new String[] { display_name }; } else { uri = Uri.parse(content://contacts/phones/filter); projection = new String[] { name }; } uri = Uri.withAppendedPath(uri, Uri.encode(phoneNumber)); Cursor c = this.getContentResolver().query(uri,projection,null,null,null); String contactName = ; if (c.moveToFirst()) { contactName = c.getString(0); } c.close(); c = null; return contactName; } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] My Anti Cracking Function
Hello everyone, I am placing next my anti-cracking\anti-reverse- engineering function. The idea of sharing this function is to allow other developers to get its benefits, and also to get more ideas for improvement, and even though exposing it to hackers makes it weaker, the idea is also that the function should be tempered by developers before using it instead of just copy/paste, and even split it into several functions to be called across your application. At the end if a hacker wants to crack your app, he will, but sure we can make it a bit harder. For the CRC validation performed in the function follow the next steps: Export a signed package of your application the same as if you would be getting ready to publish it. Rename the file extention .apk to .zip, extract the classes.dex file. Then use any internet CRC calculator tool with the extracted classes.dex file, you can find many in google (i.e.: http://www.createwindow.com/programming/crc32/crcfile.htm) Copy the obtained CRC value, go back to your IDE and open any layout xml file, place this value as the tag of any element (i.e.: android:tag=d7abbe13). Though you can really store the CRC value into other ways as an asset file, etc. I encrypt this value before passing it and decrypt it at runtime so is even harder for the hacker by not allowing him just to copy his CRC value if he finds its location. The idea is that before calling the function you should get back the CRC value and pass it. Is very important that you do not copy the CRC value into any of your java code, if after the CRC calculation you temper on any way with your code the CRC value will change and you will need to star this process again. Finally you only need to export the signed application again. The CRC will still reamin the same for the classes.dex, but somewhere hidden in your layouts you will have your CRC value to be validated by the function. As final note when developing the application do not call this function or you will get crazy :) So any comments and new ideas? /** * Validates the application integrity against reverse engineering. * If the validation fails the the application is terminated automatically without warning. * * @param context *Application context used for operations * * @param applicaionPackageName *Original application package name, you should hard-code \encrypt this string and then pass it to this function un-encrypted, do not use the java api to get this value. * * @param applicationCrc *Application CRC value */ public static void dapplicationIntegrityCheck(final Context context, final String applicaionPackageName, final String applicationCrc) { // Check that the application package name has not changed if (applicaionPackageName != context.getPackageName()) { android.os.Process.killProcess(android.os.Process.myPid()); } // Check that the debuggable flag is set to False try { if (0 != (context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).applicationInfo.flags = ApplicationInfo.FLAG_DEBUGGABLE)) { android.os.Process.killProcess(android.os.Process.myPid()); } } catch (Exception ex) { Log.e(HelperFunctions, Error checking debuggable flag., ex); } // Check that the debugger is not connected if (Debug.isDebuggerConnected()) { android.os.Process.killProcess(android.os.Process.myPid()); } // CRC validation try { ZipFile zipFile = new ZipFile(context.getPackageCodePath()); ZipEntry zipEntry = zipFile.getEntry(new String(Common.CLASS_DEX)); if (zipEntry.getCrc() != Long.parseLong(applicationCrc)) { android.os.Process.killProcess(android.os.Process.myPid()); } zipEntry = null; zipFile = null; } catch (Exception ex) { Log.e(HelperFunctions, Error checking crc., ex); } // TO-DO: // Check that the application name has not changed // Keep an encrypted string constant of the application name and the compare it // with the application name string using the proper function to retrieve it } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] My anti-cracking \ anti-reverse-engineering function
Hello everyone, I am placing next my anti-cracking\anti-reverse- engineering function. The idea of sharing this function is to allow other developers to get its benefits, and also to get more ideas for improvement, and even though exposing it to hackers makes it weaker, the idea is also that the function should be tempered by developers before using it instead of just copy/paste, and even split it into several functions to be called across your application. At the end if a hacker wants to crack your app, he will, but sure we can make it a bit harder. For the CRC validation performed in the function follow the next steps: Export a signed package of your application the same as if you would be getting ready to publish it. Rename the file extention .apk to .zip, extract the classes.dex file. Then use any internet CRC calculator tool with the extracted classes.dex file, you can find many in google (i.e.: http://www.createwindow.com/programming/crc32/crcfile.htm) Copy the obtained CRC value, remember to convert this value to a Long, as most of the these tools give you the value in HEX format. Go back to your IDE and open any layout xml file, place this value as the tag of any element (i.e.: android:tag=4212136116). Though you can really store the CRC value into other ways as an asset file, etc. I encrypt this value before passing it and decrypt it at runtime so is even harder for the hacker by not allowing him just to copy his CRC value if he finds its location. The idea is that before calling the function you should get back the CRC value and pass it. Is very important that you do not copy the CRC value into any of your java code, if after the CRC calculation you temper on any way with your code the CRC value will change and you will need to star this process again. Finally you only need to export the signed application again. The CRC will still reamin the same for the classes.dex, but somewhere hidden in your layouts you will have your CRC value to be validated by the function. As final note when developing the application do not call this function or you will get crazy :) So any comments and new ideas? /** * Validates the application integrity against reverse engineering. * If the validation fails the the application is terminated * automatically without warning. * * @param context *Application context used for operations * * @param applicaionPackageName *Original application package name, you should *hard-code\encrypt this string and then pass it to this function un-encrypted, *do not use the java api to get this value. * * @param applicationCrc *Application CRC value */ public static void dapplicationIntegrityCheck(final Context context, final String applicaionPackageName, final String applicationCrc) { // Check that the application package name has not changed if (applicaionPackageName != context.getPackageName()) { android.os.Process.killProcess(android.os.Process.myPid()); } // Check that the debuggable flag is set to False try { if (0 != (context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).applicationInfo.flags = ApplicationInfo.FLAG_DEBUGGABLE)) { android.os.Process.killProcess(android.os.Process.myPid()); } } catch (Exception ex) { Log.e(HelperFunctions, Error checking debuggable flag., ex); } // Check that the debugger is not connected if (Debug.isDebuggerConnected()) { android.os.Process.killProcess(android.os.Process.myPid()); } // CRC validation try { ZipFile zipFile = new ZipFile(context.getPackageCodePath()); ZipEntry zipEntry = zipFile.getEntry(new String(Common.CLASS_DEX)); if (zipEntry.getCrc() != Long.parseLong(applicationCrc)) { android.os.Process.killProcess(android.os.Process.myPid()); } zipEntry = null; zipFile = null; } catch (Exception ex) { Log.e(HelperFunctions, Error checking crc., ex); } // TO-DO: // Check that the application name has not changed. // Keep an encrypted string constant of the application // name and then compare it with the application // name string using the proper function to retrieve it } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: On CRC32, LVL and tamper-proof app
just in case anyone is interesting, I posted the my algorithm to avoid tempering of applications: http://groups.google.com/group/android-developers/browse_thread/thread/5e8f76ea5371f674/4637cbf1c42dfd22?lnk=gstq=crc#4637cbf1c42dfd22 On Jun 12, 11:02 pm, Kostya Vasilyev kmans...@gmail.com wrote: He can move to a different host at any time. Someone could file a DMCA notice with Blogger / Google, but at the same time, it seems useful to run his scripts on one's code, to see if it gets broken. -- Kostya 2011/6/13 String sterling.ud...@googlemail.com Wait... He's hosting this crap on BLOGGER?!? And we still can't get Google to shut the site down?? Wow. They care even less about Android piracy than I realized. String -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Unicode file names in APK
I've found out that resources placed in the Assets or Res folders with Unicode characters (i.e. Cyrillic letters) are ignored when compiling and creating the APK file, and these are not included into it. Anyone has found a solution to allow files using Unicode characters as names? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Choose a Locale Keyboard dynamically
Well, no answer from anyonw, anyway, I found a solution, which is to create dynamically at runtime my own keyboards and switch them with also dynamially. The technique is to define them in xml, and then load them via KeyboardView with the setKeyboard command. On the main layout where I want them to be displayed I have an empty layout at the bottom where keyboardView is added. The when required I swap the keybaord type by setting it through setKeyboard. On Oct 26, 3:32 pm, Sanchiski sanchi...@gmail.com wrote: is it possible to choose the keyboard that should popup when selecting an input textbox programmatically? I am writing a small application where the user should have the option to write in a textbox by using its standard keyboard, or, when pressing a button to swap to the android russian (locale built-in) keyboard. How can a set to use a specific keyboard (programmatically) for a text input control without changing the OS Locale? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Choose a Locale Keyboard dynamically
Well, no answer from anyone, but anyway I found a solution. I create dynamically at run-time my own keyboards and switch them also dynamically. The technique is to define them in xml, and then load them via KeyboardView with the setKeyboard command. On the main layout where I want them to be displayed I have an empty layout at the bottom where KeyboardView is added, I hide or show this layout when I click on the edit textbox. Also before hand I have already disabled the Android default keyboard with a simple command so only affects this specific textbox. The when required I swap the keyboard type by setting it also through setKeyboard. All at the end got very neat. On Oct 26, 3:32 pm, Sanchiski sanchi...@gmail.com wrote: is it possible to choose the keyboard that should popup when selecting an input textbox programmatically? I am writing a small application where the user should have the option to write in a textbox by using its standard keyboard, or, when pressing a button to swap to the android russian (locale built-in) keyboard. How can a set to use a specific keyboard (programmatically) for a text input control without changing the OS Locale? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Switch Soft-Keyboard
Is it possible to define which locate keyboard to popup for a specific EditText control. What I need to achieve is that depending on a a language checkbox when focusing a EditText popups a Cyrillic or latin soft-keyboard -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Slow Sqlite and Filtering ListView
I have read all posts about SQLIte and haven't found a real solution yet. -I have a database with 1000 rows, and the main search columns indexed. -These are displayed in a ListView. Since I am using the FastScroller functionality I need to load them all (1000 rows) in a cursor so there are no delays when scrolling with the FastScroller thumb. -On the layout I have a textbox on top of the listview to allow the user to filter which rows to see (if he wishes to do any filtering). -On every key stroke on the filter textbox I execute a query with the textbox value as constrain. I use the setTextFilterEnabled and run query in the background functionality. - As a note the data is stored in the database in lower case and ordered, so searching is much faster. -The search is done through a GLOB 'constrain*' command ...and still it takes around 3-5 seconds to execute every query. Is there any other option to filter a listview that isn't to perform queries all the time? I tried on the 'getView' method not to show any informaiton that doesn't fall into the constrain but doesn't work correctly as the cursor still contains all the rows and the scrollbars and fastscroller still can go through all of them showing then empty rows in the listview. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Choose a Locale Keyboard dynamically
is it possible to choose the keyboard that should popup when selecting an input textbox programmatically? I am writing a small application where the user should have the option to write in a textbox by using its standard keyboard, or, when pressing a button to swap to the android russian (locale built-in) keyboard. How can a set to use a specific keyboard (programmatically) for a text input control without changing the OS Locale? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en