How to Make Phimpme Android App Crash Free

Now Phimpme Android app is almost ready with lots of social sharing options. A user can upload images on multiple platforms like Tumblr, Flickr, Imgur, OwnCloud (open source), Nextcloud, dropbox, pinterest, etc. Apart from Sharing, Phimpme app also allow user to click image from own custom camera with different filters and various editing options. As everything is now almost ready so It also important to make app stable and crash free. To make app stable to compatible with all types of device, we can write instrumentation test cases. So in this post I will be explaining how I made Phimpme android app crash free. To do so I have integrated crash reporting service in Phimpme using Firebase Crash report service and Crashlytics. Using Firebase Crash Reporting service: Firebase is free of cost and provide various features along with crash reporting. To integrate firebase crash service there is step by step guide. Step 1: First, step is to register your app on firebase developer console. To register your Android app on firebase click here.  Add your app name and select your country.   Step 2: Next, click on the Add Firebase to your Android app button and fill in the your Android application’s package name and the SHA-1 key. You can generate this key very easily with the help of Android studio. Type this command in your terminal to generate SHA-1 keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android On successful completion of the command, the SHA-1 key will be displayed on the terminal. Step 3: Now add the SHA-1 and package name in firebase console. After that download googleservice.json file and place in app folder of your project. Step 4: Add following dependency in your android project and plugin in build.gradle dependencies {    classpath 'com.google.gms:google-services:3.1.0'  } apply plugin: 'com.google.gms.google-services' Step 5: Once you have done the above four steps your app will be visible in firebase console and now you can add crash service. Now you can see crash in your firebase console After this add the following dependency in build.gradle. This is very important. compile 'com.google.firebase:firebase-crash:9.4.0' Resources: Official firebase documentation: https://firebase.google.com/docs/crash/ Another blog: http://www.androidauthority.com/firebase-crash-reporting-764296/

Continue ReadingHow to Make Phimpme Android App Crash Free

Adding Tumblr Upload Feature in Phimpme

The Phimpme Android application along with various other cloud storage and social media upload features provides an option to upload the images on Tumblr without having to download any other applications. In this post, I will be explaining how I integrated Tumblr in phimpme as there is no proper guide on the web how to integrate to Tumblr in Android. Tumblr provides an Android-SDK but there is no proper documentation to it and is not enough to authenticate and upload the images to it. After so much research I came to a solution. So read this article to know how to integrate Tumblr in Android. Step 1: First, add two dependencies to your project one is for Android SDK of Tumblr and one is for loglr which help you to get login on Tumblr. dependencies { compile 'com.daksh:loglr:1.2.1' compile 'com.tumblr:jumblr:0.0.11' } Step 2: Register your app on Tumblr to obtain developer keys. Enter callback URL it is important to get keys. Generate CONSUMER_KEY & CONSUMER_SECRET from the official developer console of Tumblr. Register your application Step 3: Now we use Loglr library to log in to Tumblr. Tumblr doesn't provide any library to login so I am using Loglr library for login Tumblr. After successfully log in Loglr will return API_KEY and API_SECRET. We will use these keys later to upload the image. Save these keys as constant variables. public final static String TUMBLR_CONSUMER_KEY = "ENTER-CONSUMER-KEY"; public final static String TUMBLR_CONSUMER_SECRET = "ENTER-CONSUMER-SECRET"; Step 4: To authenticate the Tumblr use loglr login instance and it can be done as follows. Loglr.getInstance()      .setConsumerKey(Constants.TUMBLR_CONSUMER_KEY)      .setConsumerSecretKey(Constants.TUMBLR_CONSUMER_SECRET)      .setLoginListener(loginListener)      .setExceptionHandler(exceptionHandler)      .enable2FA(true)      .setUrlCallBack(Constants.CALL_BACK_TUMBLR)      .initiateInActivity(AccountActivity.this); After that you will be prompt to enter your tumblr credentials to authenticate the phimpme Android app. Once you have done it will return api_token and api_secret. Now save this in database. account.setToken(loginResult.getOAuthToken()); account.setSecret(loginResult.getOAuthTokenSecret()); Step 5: Once the authentication is done now we can upload an image directly to Tumblr from the Share activity in the Phimpme Android application. To upload an image create an async task so that uploading process will run in a background thread and not block the main UI thread. Keep in mind Tumblr require 4 variable to create Tumblr client CONSUMER_KEY, CONSUMER_SECRET, API_KEY and API_SECRET. Now we can create a Tumblr client using these 4 values. Once the client is created we are ready to get data from Tumblr and upload an image on Tumblr. Before uploading an image on Tumblr we need blog name because the user can have multiple blogs on Tumblr so we need to ask the user to choose a blog name from the list or we can provide dialog to enter blog name manually. Now enter the following code in the doInBackground() method of asynctask. PhotoPost post = null; try {  post = client.newPost(user.getBlogs().get(0).getName(), PhotoPost.class);  if (caption!=null && !caption.isEmpty())  post.setCaption(caption);  post.setData(new File(imagePath));  post.save(); } catch (IllegalAccessException | InstantiationException e) {  success = false; } If success variable is true that means our image is uploaded successfully. This is how I implemented the…

Continue ReadingAdding Tumblr Upload Feature in Phimpme

Uploading Images to Box Storage from the Phimpme Application

The Phimpme Android application along with many other cloud storage applications integrated like Dropbox, Imgur, Pinterest has the option to upload the image to the Box storage without having to install any other applications on the device. From the Phimpme app, the user can click the photo, edit it, view any image from the gallery and then can upload multiple images to many storage services or social media without any hassle. In this tutorial, I will be discussing how we achieved the functionality to upload the images on the Box storage. Step 1: To integrate Box storage to the application, the first thing we need to do is create an application from the Box developers console and get the CLIENT_ID and the CLIENT_SECRET. To do this: Go to the Box developer page and log in. Create a new application from the app console. It will now give options to select what kind of application are you using. Select the option partner integration to get the image upload functionality to all the users. Give a name to your application and finally click the create application button. After this, you will be taken to the screen similar to the below screenshot from where you can copy the CLIENT_ID and CLIENT_SECRET to be used later on. Step 2: Now coming to the Android part, to get the image upload functionality to the box storage, we need to make use of the Android SDK provided by Box to achieve the uploading functionality easily. To add the SDK to the Android project from Gradle, copy the following line of Gradle script which will download and install the SDK from the maven repository. maven{ url "https://mvnrepository.com/artifact/com.box/box-android-sdk" } compile group: 'com.box', name: 'box-android-sdk', version: '4.0.8' Now after adding the SDK, rebuild the project. Step 3: After this, to upload the file on the box storage, we need to login to the Box account to get the access token and the user name to store it in Realm database. For this, first we have to configure the Box client. This can be done using the following line of code. BoxConfig.CLIENT_ID = BOX_CLIENT_ID; BoxConfig.CLIENT_SECRET = BOX_CLIENT_SECRET; Replace the BOX_CLIENT_ID and BOX_CLIENT_SECRET in the above code with the key received by following the step 1. After configuring the Box API client, we can authenticate the user using the sessionBox object by following lines of code. sessionBox = new BoxSession(AccountActivity.this); sessionBox.authenticate(); After the authentication, we have to get the user name and the access token of the user using the authenticated session box. account.setUsername(sessionBox.getUser().getName()); account.setToken(String.valueOf(accessToken)); After authenticating the user, we can upload the photos directly to the Box storage from the Share Activity in the Phimpme Android application. For this, we have to create a new Asynchronous task in android which will do the network operations in the background to avoid the Network on main thread exception. After this, we can make use of the Box file API to upload the photos to the Box storage and call the function getUploadRequest…

Continue ReadingUploading Images to Box Storage from the Phimpme Application

Getting user Location in SUSI Android App and using it for various SUSI Skills

Using user location in skills is a very common phenomenon among various personal assistant like Google Assistant, Siri, Cortana etc. SUSI is no different. SUSI has various skills which uses user’s current location to implement skills. Though skills like “restaurant nearby” or “hotels nearby” are still under process but skills like “Where am I” works perfectly indicating SUSI has all basic requirements to create more advance skills in near future. So let’s learn about how the SUSI Android App gets location of a user and sends it to SUSI Server where it is used to implement various location based skills. Sources to find user location in an Android app There are three sources from which android app gets users location : GPS Network Public IP Address All three of these have various advantages and disadvantages. The SUSI Android app uses cleverly each of them to always get user location so that it can be used anytime and anywhere. Some factors for comparison of these three sources : Factors GPS Network IP Address Source Satellites Wifi/Cell Tower Public IP address of user’s mobile Accuracy Most Accurate (20ft) Moderately Accurate (200ft) Least Accurate (5000+ ft) Requirements GPS in mobile Wifi or sim card Internet connection Time taken to give location Takes long time to get location Fastest way to get location Fast enough (depends on internet speed) Battery Consumption High Medium Low Permission Required User permission required User permission required No permission required Location Factor Works in outdoors. Does not work near tall buildings Works everywhere Works everywhere Implementation of location finding feature in SUSI Android App SUSI Android app very cleverly uses all the advantages of each location finding source to get most accurate location, consume less power and find location in any scenario. The /susi/chat.json endpoint of SUSI API requires following 7 parameters : Sno. Parameter Type Requirement 1 q String Compulsory 2 timezoneOffset int Optional 3 longitude double Optional 4 latitude double Optional 5 geosource String Optional 6 language Language  code Optional 7 access_token String Optional In this blog we will be talking about latitude , longitude and geosource. So, we need these three things to pass as parameters for location related skills. Let’s see how we do that. Finding location using IP Address: At the starting of app, user location is found by making an API call to ipinfo.io/json . This results in following JSON response having a field “loc” giving location of user (latitude and longitude. { "ip": "YOUR_IP_ADDRESS", "city": "YOUR_CITY", "region": "YOUR_REGION", "country": "YOUR_COUNTRY_CODE", "loc": "YOUR_LATITUDE,YOUR_LONGITUDE", "org": "YOUR_ISP" } By this way we got latitude, longitude and geosource will be “ip” . We find location using IP address only once the app is started because there is no need of finding it again and again as making network calls takes time and drains battery. So, now we have user’s location but this is not accurate. So, we will now proceed to check if we can find location using network is more accurate than location using IP…

Continue ReadingGetting user Location in SUSI Android App and using it for various SUSI Skills

Join the FOSSASIA Community Network

The FOSSASIA.net project is an initiative to bring the Asian Free and Open Source Software and OpenTech community together and foster cooperation. We make it easy to find communities and projects on a map with links to the websites, social media channels, and automatically updated info from community blogs. Communities store their information decentrally anywhere on the web - on their server, a blog, or git service. FOSSASIA.net collects information through a stardardized API file on the web. You can generate the API file with the FOSSASIA API generator on our website. Then you add your community to the FOSSASIA network website. Simply add the link of your API file to our list of communities on github. FAQ How does it work? You need to provide a file for our API and add the file to our communities repository. Then fill in the link to your API on our directory on github. That is it! Where can I store my file? We prefer that you store your file in our github repository of communities: https://github.com/fossasia/fossasia-communities. It is also possible to store it anywhere on the web, where it is publicly available, e.g. in a blog or CMS page as an attachment. However the github repo is the preferred method currently. How about updating my file? If you need to update your links, just upload a new file in the same location. How do I start? To make it easier, we created a FOSSASIA API Generator, where you can simply fill in your data here: http://api.fossasia.org/generator When you are finished copy the info from the form on the top right into an empty file or use the download button. How do I find Geolocation data of my community? You can find this data from OpenStreetmap. OpenStreetmap shows maps using a URL of the form: www.openstreetmap.org/#map=[Zoom Level]/[Latitude]/[Longitude] So go to www.openstreetmap.org and zoom to the area of your community. For example, if you are zoom into Mumbai, you will get the URL http://www.openstreetmap.org/#map=11/19.0715/72.9499 Then 19.0715 will be the latitude and 72.9499 the longitude. What is an API? In computer programming, an application programming interface (API) is a set of routines, protocols, and tools for building software applications. An API expresses a software component in terms of its operations, inputs, outputs, and underlying types. An API defines functionalities that are independent of their respective implementations (e.g. It does not matter what CMS is used), which allows definitions and implementations to vary without compromising each other. Compare: en.wikipedia.org/wiki/Application_programming_interface Links * Website http://fossasia.net * Map http://fossasia.net/map/map.html * FOSSASIA Community Network Tweets https://twitter.com/fantwk

Continue ReadingJoin the FOSSASIA Community Network