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.