How to make Patch Request to server on Android

What’s a Patch request?
On Android, we generally use 4 types of HTTP requests during server side communication; POST, GET, PUT and DELETE. PATCH isn’t one of them. It requests a set of changes described in the request entity to be applied to the resource identified by the Request-URI. You can use this in case you want to update only one field of a resource; saving bandwidth compared to using the PUT request.

Code snippet:

[code language=”html”]
JsonObjectRequestpatchRequest = new JsonObjectRequest(Request.Method.POST,url, jsonObject,
newResponse.Listener<JSONObject>()
{
@Override
public void onResponse(JSONObject response) {
// display response
// Log.d("Response", response.toString());

}
},
newResponse.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
Log.d("Error.Response", error.getMessage());

}
}
){
@Override
public Map<String, String>getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("X-HTTP-Method-Override","PATCH");
headers.put("Content-Type","application/json");
return headers;
}
};
MyApplication.getInstance().getRequestQueue().add(patchRequest);
[/code]

We, at Andolasoft are experts in developing glitch free, seamless & cost-effective Android apps. If you have an idea, please share to us and let’s have a talk to take it from there.

Also, please share your suggestions below.

How To Choose A Perfect WordPress Theme

WordPress is amazing because it requires minimal technical knowledge and saves time. However, few things need to be taken into consideration while selecting the perfect WordPress theme for your website. This article will help you in doing so.

WordPress Theme

Conclusion

UI should always be the main factor while finalizing a theme. However, a WordPress theme is not all. To get an engaging, productive & hassle free site, it’s always better to allow professionals do it for you.

Andolasoft, known for its excellent contribution in developing Web & Mobile apps, provides expert WordPress services tailor-made for you.

 

Need to Setup Your WordPress Site? Let’s get in touch for a quick discussion

How To Get Your IOS App On The App Store

Every iOS application developed for public use must be approved by Apple, before it’s released on the App Store. The process is pretty straightforward, with just a form to be filled up. However, finalizing the launch date has its challenges when you are not sure how long Apple would take to give the green light.

There are three things you must be aware of: the guidelines, available resources and your options.

Reviewing the application guidelines for App Store ahead of time can save you major headaches if your app is rejected due to unnecessary code or incorrect use of the ad framework. Even then, it doesn’t always guarantee acceptance, so be ready to respond quickly to any issues that may arise after the submission process starts.

Make sure you pay attention to the unofficial app review time. New apps take anywhere from a few days to a couple of weeks for approval. However, updates tend to take longer than the existing versions.

Never miss an update from us. Join 10,000+ marketers and leaders.

Expediting the process is an option. However, use this only when necessary. A justifiable expedition request falls into one of the two categories: an urgent bug fix (when a third-party API changes causing your app to crash on launch) or any time-sensitive event. Remember that these requests are taken only at Apple’s discretion.

Apple reviews each & every app against these ever-changing guidelines before approving it for inclusion on the App Store.

Make sure after your app is approved, you need to release it manually to appear on the App Store. Most of the time, this is done to ensure both the Android and iOS versions are available on the same day.

Ref – Willowtree

Conclusion: Converting a great Idea to an awesome iOS App is by no means a tough job. But that’s not all! Deploying it successfully to the App Store is not behind.

With a skilled pool of experienced and innovative folks, we at Andolasoft design, develop and deploy disruptive mobile apps.
300+ apps and counting… We follow agile methodology and help customers with cutting edge solutions to monetize their ideas & improve the return on investment (ROI). If you’re thinking of having an iOS App for your own, we would love to get in touch.

How To Insert Multiple Rows In CakePHP 3

One of my many issues with CakePHP 2 was lack of multi-row inserts. Cake2 allows saving multiple rows through a single call via saveMany but the issue is with a bunch of single row inserts which can be really slow down when inserting large data; unlike CakePHP 3. Here is what I did to fix this:

[code language=”html”]
$sql = "INSERT INTO `people` (`name`, `title`) VALUES ";
foreach ($people as $person){
list ($name, $title) = $person;
$sql.= "(‘$name’,’$title’),";
}
$this->query (substr ($sql, 0,-1));
[/code]

This sucks since I’m not using any framework and I’m also not using PDO bound parameters.

Cake3 has the fixes with the new Query Builder ORM.

[code language=”html”]
$peopleTable = TableRegistry::get (‘People’);
$oQuery = $peopleTable->query ();
foreach ($people as $person) {
$oQuery->insert ([‘name’,’title’])
->values ($person); // person array contains name and title
}
$oQuery->execute ();
[/code]

The key here is not to issue execute () until after you’ve added all your data via insert (). This will return an instance of the PDO Statement object which inherits all sorts of valuable methods including count () which would give you the total number of rows inserted and errorInfo () for query errors.

Did you find the above tips useful? Feel free to drop in your suggestion…

Please visit Andolasoft’s CakePHP Service to know more.

Module In Ruby And Its Usages In Rails

Ruby is an Object Oriented Programming (OOP) language. This programming language based upon various components such as classes, object, variables etc. Ruby also provides a nice building block for applications, and which is known as module. A module is a collection of methods and constants. It defines a namespace in which other methods and constant can’t step on your methods and constants.

Purpose of a Module:

Ruby module is a component to regroup similar things. Ruby methods, classes and constants can be grouped by similarity with the help of modules.

Here is the Two benefits provide by the modules

  • Ruby provide ‘namespace’, and which basically helps to prevent name clashes.
  • Ruby’s ‘mixin’ facility is implemented with the help of modules.

The basic syntax of module is:

[code language=”html”]
module Identifier
statement1
statement2
………..
End
[/code]

Uses:

Ruby module mainly functions as a namespace. It lets us define various methods for the actions that will perform. When a method defined inside a module does not clash with other methods that are written anywhere else, though they’re having the same names.

Module constants are named like class constants with an initial uppercase letter. This are module methods, and also defined like class methods.

Here is an example.

[code language=”html”]
module MyModule
def method
puts “hello”
end
end
[/code]

To access the methods and constants inside a module in a class include key word is used.

[code language=”html”]
class Customer &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt; ActiveRecord::Base
include MyModule
end
[/code]

To use the method that is defined inside a module, specify the module name followed by a dot and then the method name.

Ruby Mixins and Ruby Modules:

Ruby is purely an OOP language. But it does not support multiple inheritances directly, which is handled beautifully by Modules. They provide a facility called ‘mixin’ that eliminates the requirement of multiple inheritance. In Ruby when ‘mixins’ are called and used in proper manner they provide high degree of versatility functionality.

Never miss an update from us. Join 10,000+ marketers and leaders.

A module ‘mixin’ generally consists of several lines of codes to set up conditions where the module can mix in with a class or classes to improve the functionality of the class or itself too. Here is an example of a module ‘mixin’.

[code language=”html”]
module A
def a1
end
def a2
end
end

module B
def b1
end
def b2
end
end

class MyClass
include A
include B
def s1
end
end

obj = Objet.new
obj.a1
obj.a2
obj.b1
obj.b2
obj.s1
[/code]

Here module A and B consist of two methods individually. They are included in the classMyClass. Now MyClass can access all the four methods a1, a2, b1, b2. So it can be said that Myclass inherits from multiple modules. Thus multiple inheritances are implemented with the help of module’s ‘mixin’ facility.

Conclusion:

Modules don’t have any direct analogy in any mainstream programming language. They are used mostly in Ruby language. They are one of the key features making Ruby’s design beautiful. With the facility of ‘namespacing’ and ‘mixin’ modules make Ruby more flexible Object Oriented Programming language. They also make the application highly secure as classes and their objects inherit from modules and modules are having ‘mixins’.

Planning something with RoR? We would love to get in touch with you.

Android: How to Solve Video Compression

A high quality recording by an Android phone for 30 seconds is around 40 to 45 MB in size; storage space is not a concern now-a-days! However, it is a concern for anyone while sharing the video through an app or mail. For example, sharing it in WhatsApp is a problem, as the app does not support videos more than 16 MB in size. This article will help you in Video Compression so that you can share it easily!

What is Video Compression?
Video compression uses modern coding techniques to reduce redundancy in video data. Most video compression algorithms and codecs combine spatial image compression and temporal motion compensation. Most video codecs also use audio compression techniques in parallel to compress the separate, but combined data streams as one package.

To implement the video compression in Android we need a video to be recorded with the surfaceView and a Media recorder. Therefore, before starting a video recording we need to set the required parameters to the Media recorder like the Video Frame Rate, Video Size, Video Encoder, and Video Encoding Bitrate.

Compressing a video of 20MB can reduce to 2 to 4 MB, helping users to a much faster sharing/uploading.

Here’s the code snippet for compressing a video file in the Android app.

[code language=”html”]
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setVideoEncodingBitRate(690000);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setVideoFrameRate(30);
mediaRecorder.setVideoSize(640, 480);
[/code]

Conclusion

Compressed video files will take less time to Upload, Sync, Share while saving storage space. However, compressing a video file may reduce the video quality depending upon the settings that have been applied.

Sources: http://bit.ly/1WBuhEX, http://bit.ly/27w20CY