android
React Native Android build failure with different errors without any changes in code for past days due to publish of React Native version 0.71.0-rc.0
The build failures for Android was due to the publish of the React Native version 0.71.0-rc0. Note: Error may be different but this would be the solution if you are getting android build failures without any changes in code for past two days before trying these methods please revert back every changes you have done … Read more
Shared preferences for creating one time activity
Setting values in Preference: // MY_PREFS_NAME – a static String variable like: //public static final String MY_PREFS_NAME = “MyPrefsFile”; SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit(); editor.putString(“name”, “Elena”); editor.putInt(“idName”, 12); editor.apply(); Retrieve data from preference: SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE); String name = prefs.getString(“name”, “No name defined”);//”No name defined” is the default value. int idName = prefs.getInt(“idName”, … Read more
get the last picture taken by user
// Find the last picture String[] projection = new String[]{ MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA, MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.MIME_TYPE }; final Cursor cursor = getContext().getContentResolver() .query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.ImageColumns.DATE_TAKEN + ” DESC”); // Put it in the image view if (cursor.moveToFirst()) { final ImageView imageView = (ImageView) findViewById(R.id.pictureView); String imageLocation = cursor.getString(1); File imageFile = new File(imageLocation); if … Read more
C2DM implementation PHP code
To register your own server system and obtain the Authorise Tokens (this is what Cpt. Ohlund proposed): function googleAuthenticate($username, $password, $source=”Company-AppName-Version”, $service=”ac2dm”) { session_start(); if( isset($_SESSION[‘google_auth_id’]) && $_SESSION[‘google_auth_id’] != null) return $_SESSION[‘google_auth_id’]; // get an authorization token $ch = curl_init(); if(!ch){ return false; } curl_setopt($ch, CURLOPT_URL, “https://www.google.com/accounts/ClientLogin”); $post_fields = “accountType=” . urlencode(‘HOSTED_OR_GOOGLE’) . “&Email=” . … Read more
java.lang.ClassNotFoundException: org.postgresql.Driver, Android
You need to add the PostgreSQL JDBC Driver in your project as mentioned in search.maven.org. Gradle: implementation ‘org.postgresql:postgresql:42.2.10’ Maven: <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.10</version> </dependency> You can also download the JAR and import to your project manually. NOTE: Compile as used in this answer is deprecated. Replace with implementation as per 3.
Find out the running process ID by package name
Since Android 7.0 the easiest way to find out the process ID by package name is to use pidof command: usage: pidof [-s] [-o omitpid[,omitpid…]] [NAME]… Print the PIDs of all processes with the given names. -s single shot, only return one pid. -o omit PID(s) Just run it like this: adb shell pidof my.app.package … Read more
how to convert rgb color to int in java
First of all, android.graphics.Color is a class thats composed of only static methods. How and why did you create a new android.graphics.Color object? (This is completely useless and the object itself stores no data) But anyways… I’m going to assume your using some object that actually stores data… A integer is composed of 4 bytes … Read more
Load large images with Picasso and custom Transform object
I found a solution.. In my Transform object I needed to scale the image (keeping aspect ratio) to 1024 x 768 max. Transform object was never called unless I call .resize(width, height) to resample down the image. For keeping aspect ratio and using resize I call .centerInside(). This way image will be scaled resample to … Read more