Android Snippets - Latest Commentshttp://www.androidsnippets.comAndroidSnippets is a community driven website for finding, exploring, sharing and improving source code snippets for Android.Sun, 05 Feb 2012 08:08:45 GMTPyRSS2Gen-1.0.0http://blogs.law.harvard.edu/tech/rssNew comment on 'How to set up a BroadcastReceiver intent'http://www.androidsnippets.com/how-to-set-up-a-broadcastreceiver-intent<p>String action = intent.getAction(); if (action.equals(LogService.DB_INTENT)) { <br /> </p> <p>Good Coad </p> <p>http://www.genericprozacworld.com</p>http://www.androidsnippets.com/how-to-set-up-a-broadcastreceiver-intentSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Buy Prozac Online'http://www.androidsnippets.com/buy-prozac-online<p>Buy generic prozac Fluoxetine 10 mg online to treat major depression. Purchase prozac 10mg , 20mg, 40 mg and 60 mg in 30 and 90 tablets for very cheap and reasonable prices http://www.genericprozacworld.com</p>http://www.androidsnippets.com/buy-prozac-onlineSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Autostart an application at bootup'http://www.androidsnippets.com/autostart-an-application-at-bootup<p>Thanks for this code snippet. A very useful one..</p> <p>chandu http://www.geekland.co</p>http://www.androidsnippets.com/autostart-an-application-at-bootupSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Autostart an application at bootup'http://www.androidsnippets.com/autostart-an-application-at-bootup<p>This is a great idea indeed. If Android had a function to auto-start an app without a programmatic way it would indeed give that power to users to default to an app at start up.</p> <p>Chandu http://www.geekland.co We are an Atlanta, Georgia based company focused on custom Android Tablet design and development services. We provide both OEM (Original Equipment Manufacturer) and ODM (Original Design Manufacturer) services. By partnering with high quality and reliable manufacturing companies in China, we are able to design and build high quality Android tablets to custom specifications.</p>http://www.androidsnippets.com/autostart-an-application-at-bootupSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Ok I'm so stupid. I got it to work by changing this line in the java-code, like you said: char paddingChar = ' '; to this char paddingChar = 0;</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>From one Jan to another;</p> <p>I have the exact same problem as you had, but I can't seem to really understand what part of the code you changed for it to work. Would you mind elaborating? Sorry for being a beginner at this :)</p> <p>All the best, Jan</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi,</p> <p>I have found the solution for my problem... In the php-code it is state that padding is done using the 0 character, in your example you are doing padding with ' ' (space). If I change that, the encrypted text that I got from php and java are both the same!</p> <p>Kind regards, Jan</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi, well the resulted text is not really the issue (for now) but the encrypted message is already different between php and java so that makes me wonder what's going wrong... </p> <p>I'm also investigating it since I need this really for a project of mine so let's hope we can find some solution for this.</p> <p>Thanks anyway! Jan</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi, I have to look deeper in the code but I found that in Java for "Text to encrypt" when I decode the encrypted result what I got is: string(32) "Text to encrypt " (with an added character at the end)</p> <p>Maybe if you trim the resulted text you can get the same string.</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>It's AES-128 as you can see the key is 16 bytes long. If you multiplied 16 bytes (Key) by 8 (1 byte = 8 bits) you get 128bits. I just posted is for example purposes. You can modify the code and set the encryption method you want.</p> <p>I hope this explains your questions. </p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Just to understand it: Is this AES-128, AES-196 or AES-256? And why?</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi,</p> <p>I have added all the above changes, but I'm still getting the same result... What is the expected result to have when you encrypt the "Text to encrypt" with the above algorithm? So that I know whether I have to investigate Java or PHP code...</p> <p>When I use the AES/CBC/PKCS5Padding I even get: beb4ce4c41a3c3445be48ad55906f5bc9e020255d861b1a91de5f1ecc3a75b2f</p> <p>Thanks, Jan</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi!</p> <p>That's because of the extra characters were inserted in Java.. try to add the changes on the previous comment and see if it's the same..</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi,</p> <p>When I use your example (without any changes) on Android and Php, I don't get the same encrypted value. Is this normal?</p> <p>For Java I'm getting: beb4ce4c41a3c3445be48ad55906f5bc And for PHP I'm getting: cb4b4ca864213684070465b38783a6c8</p> <p>Do you have any idea what the reason for this difference could be?</p> <p>Kind regards and thanks! Jan</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Works for me in either way.. but I'm glad it finally works for you! :)</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Still the same problem. But after many hours i found the failure. :) Just replace cipher = Cipher.getInstance("AES/CBC/NoPadding"); with cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");</p> <p>Thx for your help. Btw: Very good script. :)</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Ok I found the problem in JAVA, just replace the bytesToHex method with:</p> <pre><code>public static String bytesToHex(byte[] b) { StringBuffer buf = new StringBuffer(); int len = b.length; for (int j=0; j&lt;len; j++) buf.append(byteToHex(b[j])); return buf.toString(); } public static String byteToHex(byte b) { char hexDigit[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; char[] a = { hexDigit[(b &gt;&gt; 4) &amp; 0x0f], hexDigit[b &amp; 0x0f] }; return new String(a); } </code></pre>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'How to Make an Activity Fullscreen'http://www.androidsnippets.com/how-to-make-an-activity-fullscreen<p>Wow, so well. I consider computer programming is hard for me. Do you use language of C? http://www.topckit.com</p>http://www.androidsnippets.com/how-to-make-an-activity-fullscreenSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi again. Hard-coded and input string via EditText on Eclipse and on Smartphone.</p> <p>Here the Code in Android:</p> <p><img alt="alt text" src="http://www.tmamedia.de/gfx/img_a.png" title="Sourcecode" /></p> <p>And here what i get:</p> <p><img alt="alt text" src="http://www.tmamedia.de/gfx/img_b.png" title="Result" /></p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>is the String with special chars hard-coded in your project or is it an input string from the smartphone? If you want, you can send me the part of the source where you use it and it fails so I can test it locally. My email is like my username [at] gmail [dot] com</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>If the String contains special chars, he abort the script near this:<code>encrypted = cipher.doFinal(padString(text).getBytes());</code> I dont know why, but this problem is in Eclipse and on smartphones. :(</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>I tried it in Java and it seems to work fine, do you have problems with Java too?</p> <p>I created this code and it worked:</p> <pre><code>import javax.swing.JOptionPane; public class testJava { public static void main(String args[]) { String value = JOptionPane.showInputDialog("Enter a string:"); /** * ENCRYPT / DECRYPT */ try { MCrypt mcrypt = new MCrypt(); String encrypted = MCrypt.bytesToHex( mcrypt.encrypt( value ) ); JOptionPane.showMessageDialog(null, encrypted); String decrypted = new String(mcrypt.decrypt( encrypted )); JOptionPane.showMessageDialog(null, decrypted); } catch (Exception e) { e.printStackTrace(); } } } </code></pre>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Thx very much, and in Java? :) I tried my best, but i couldn't figure it out. :D</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Sure.. I don't know why I missed that. you need to change the encrypt and decrypt method on your php class:</p> <pre><code>function encrypt($str) { [...] $encrypted = mcrypt_generic($td, utf8_encode($str)); [...] } function decrypt($code) { [...] return utf8_decode(trim($decrypted)); } </code></pre> <p>I hope it helps</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Is it possible to support special chars like the euro sign and german vowel mutations? What do i have to change?</p> <p>Greetings</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi again,</p> <p>I just looked again at my code, and I don't use any kind of trim on the Java side to decrypt the text, but as the source is available feel free to modify whatever you want. You can modify the decrypt function to return a String instead of byte array and trim it before you return it.</p> <p>I hope this will help you</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi Thomas, When you use that String to create the JSONObject or JSONArray do you get any errors? because I do the same and it's working fine, though I think I don't have that extra character.</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Encrypt / Decrypt Between Android and PHP'http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php<p>Hi SeRPRo, thanks for the response :) actually I am doing this in Java code, and it seems that it should be also trimmed there. I just wondered if you had to do this or not. e.g. when I encrypt and then decrypt "qwe", decrypt(...) method returns "qwe " with spaces at the end.</p>http://www.androidsnippets.com/encrypt-decrypt-between-android-and-phpSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Prompt engaged users to rate your app in the Android market (AppiRater)'http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater<p>Also, wrap that line in these lines: runOnUiThread(new Runnable() {</p> <pre><code> @Override public void run() { // TODO show the dialog } }); </code></pre>http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appiraterSat, 06 Sep 2003 21:31:00 GMTNew comment on 'Prompt engaged users to rate your app in the Android market (AppiRater)'http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater<p>kmartinho8, not sure exactly whats not working. You could try fixing this line: AppRater.showRateDialog(YourActivity.this, null);</p>http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appiraterSat, 06 Sep 2003 21:31:00 GMT