Showing posts with label Android. Show all posts

Android Stack Careers Pull Request - Feed API and OkHttp

by GarciaPL on Sunday, 18 September 2016

Some of you might know this unofficial Stack Careers Android app which allows you search job in IT sector. There is a link => Stack Careers on Google Play. I have been using it for a while, but some time ago it stopped working. Only what I got was : 'No Results'. So, I downloaded repository and found out that feed API of Stack Careers has been changed. I mean that application got HTTP 301 status which means Moved Permanently and no redirect has been performed using standard HttpConnection component of Android stack. More info about what I did you might find below and under pull request link.


In fact that I have been using you app occasionally, I found someday that it does not work now. I managed to figure out that guys from Stackoverflow changed feed API and moreover you app was not able to follow up redirect (HTTP 301 Moved Permanently).

So, according to this pull request what I did and what I did not :

  • feed API has not been changed 
  • added OkHttp library within required by it another library called Okio 
  • replaced HttpURLConnection with client from OkHttp 
  • added required rules for proguard to cover up OkHttp 
I pushed changed content around usage.txt, seeds.txt, mapping.txt and dump.txt within this pull request, but I will leave decision up to you if you are going to discard it or not.

I also would like to mention that feed API for Stack careers has been changed from
http://careers.stackoverflow.com/jobs/feed => https://stackoverflow.com/jobs/feed

PS. I hope that author of Stack Career will accept my fix for that problem and eventually some day we might be able to download new app from Google Play.

Reference :
[1] Stack Careers - pull request

Face Slim - light Facebook for Android phones

by GarciaPL on Saturday, 18 June 2016

If you are trying to speed up your Android phone, you should consider uninstalling Facebook! You can read more about that phenomenon for instance here : https://www.reddit.com/r/Android/comments/42kyph/uninstalling_facebook_speeds_up_your_android/. To be honest my phone is much faster after removing Facebook.

After uninstalling Facebook, you might looking for replacement. There is a application called Face Slim [1]. Maybe it is not perfect, but if you only view posts on Facebook and put comment occasionally, it might be totally fine.

Recently I installed this application on Samsung Galaxy S3. After running it, I found that I am not able to login due to bad rendering of login screen [2]. Only what you need to do, is clearing UA (User Agent) settings in application.

Reference :

PerlJobs

by GarciaPL on Thursday, 31 March 2016

I would like to announce that new Android app has been released recently times by me. This time application is called PerlJobs. This application helps you as a Perl developer to find new job opportunities across the globe. Job offers are divided into sections : Standard, Mod, Catalyst, Mason, Telecommute and By Country. The main source of all jobs is website : https://jobs.perl.org

Google Play Developer Page

by GarciaPL on Sunday, 6 March 2016

Yes! I finally managed to create it. Obviously it is not so pretty as it might be, but.. never mind :) If you would like to create your own Google Play Developer Page where you can add some promotion text and graphics (icon and background), just go to your Developer Console and then click Settings and then Developer Page. If you are looking for let's say 'inspiration', you can have a look on my Developer Page which link you can find below :





Android Material Design with AppCompat

by GarciaPL on Wednesday, 6 January 2016

I just would like to show you how setup styles.xml and values-v21/styles.xml to use Material Design with AppCompat. First of all rename styles21.xml as styles.xml and place in your res/values-v21 folder (you may need to create a values-v21 folder if you don't already have one). Below you might found AndroidManifest.xml.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="uk.co.thewirelessguy.myappname" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="uk.co.thewirelessguy.myappname.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Then change your build.gradle to provide appropriate compileSdkVersion and buildToolsVersion.


apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "uk.co.thewirelessguy.myappname"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.0'
}

After that you can apply styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="AppTheme.Base"/>

    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->

        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/colorPrimary</item>

        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

        <!-- colorAccent is used as the default value for colorControlActivated
             which is used to tint widgets -->
        <item name="colorAccent">@color/colorAccent</item>

        <!-- You can also set colorControlNormal, colorControlActivated
             colorControlHighlight & colorSwitchThumbNormal. -->
    </style>

</resources>

And also style for v21

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="AppTheme.Base">
        <!-- Customize your theme using Material Design here. -->
    </style>
</resources>


Reference :  [1] https://gist.github.com/thewirelessguy/1875ddb114bda7407402

Android Cron Service

by GarciaPL on Thursday, 12 November 2015

I would like to publish a very useful snipper of code to create cron service in your Android app. Of course you might use some libraries created by other developers. A lot of them might be found on site called Android Arsenal [1] which also I would like to recommend for developers who are looking for libraries.

So, First of all you need to create Handler [2] object which allows you to send and process Runnable objects. This object has a lot of methods which might help you to define expected behavior of your code. This time I will use method postDelayed which allows to execute some Runnable with delay.

private Handler handler = new Handler();

And then we can define Runnable with task in it which should be executed with given delay


Runnable networkReceiverTask = new Runnable() {
        @Override
        public void run() {
            //execute here method with given delay
            handler.postDelayed(networkReceiverTask, 15000);
        }
    };


Reference:
[1] Android Arsenal Job Schedulers
[2] Android Handler

Android Progress Loading Dialog

by GarciaPL on Monday, 9 November 2015

Some of you might be looking for some solution to display progress loading dialog. I have used below example it in one of my Android application compiled against API 23 (Android 6.0). That's why on first glance you might think that style theme which I used in this case is overloaded. You need just to adjust it to your own purposes.

<style name="LoadingDialogTheme">
    <item name="colorAccent">#1976D2</item>
    <item name="android:textColor">#1976D2</item>
    <item name="android:textColorPrimary">#1976D2</item>
    <item name="android:textColorSecondary">#1976D2</item>
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:background">@android:color/transparent</item>
</style>

Above style should be added in styles.xml. Then you can use this style with ProgressDialog as below.


ProgressDialog progressDialog = new ProgressDialog(MainActivity.this, R.style.LoadingDialogTheme);
progressDialog.setMessage(getString(R.string.dialog_loading_content));
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(true);
progressDialog.show();


And the final result is as this one :


ROME Parsing RSS

by GarciaPL on Sunday, 30 August 2015

A few days I was looking for some library to parsing RSS feeds in Java mainly for Android purpose. For me it was quite obvious that I will pick up library called ROME because of I have still a pretty good feeling about it from previous projects. Below you can find my piece of code which is very similar to this one on ROME website.

URL url = new URL("https://www.centralbank.ie/Pages/RSSFeedDisplay.aspx?FeedID=20");
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(url));
List entries = feed.getEntries();

logger.info("Size : " + entries.size());
Iterator iterator = entries.iterator();
while (iterator.hasNext()) {
      SyndEntry entry = (SyndEntry) iterator.next();
      logger.info("Entry : " + entry.getTitle() + " " + entry.getAuthor() + " " + entry.getLink());
}

If you will use official ROME library [1] on Android you will be faced with this error :
ERROR/AndroidRuntime(263): java.lang.NoClassDefFoundError: [Ljava.beans.PropertyDescriptor;
This error occurred due to lack of libraries on Android platform related to java.beans package. Fortunately there is a way to parse this RSS on Android platform properly. Only what you need to do is download fork of ROME library called AndroidROMEFeedReader [2] and apply jdom-1.1.1-android-fork.jar and android-rome-feed-reader-1.0.0.jar to your project in Android Studio. From this moment you will be able to fetch and parse RSS without including java.beans package to your project.

Reference: [1] ROME [2] GitHub AndroidROMEFeedReader [3] Docs Oracle Java Beans

TrafficCity BIHAPI Orange

by GarciaPL on Saturday, 14 March 2015

Today I have released on GitHub two repositories which contain one of my recent project called TrafficCity. It was developed on hackathon called BIHAPI (Business Intelligence Hackathon API) organized by Orange Poland.

Briefly describing what's it's about in this app - on the mobile app you can place your markers (waypoints) on Google Maps which describes your daily route to work/school. After that you can send those waypoints to server to further processing.

In Backend you can see what's routes are defined by users. Additionally you can upload OSM file which is strongly related with OpenStreetMap and after that you can see on particular area what's is the chance to appear traffic jam.

An application consists of Backend app written in Spring and mobile app written in Android. Application was mainly deployed on JBoss AS 7.1. Backend part is also using interfaces provided by Orange - SIM GeoLocalization API, SMS API, USSD API and by Warsaw City - Transport POI Maps.

Unfortunately, I think that application which is in alpha phase, probably would remain so. There a few things to do/fix on the Backend and Mobile part, but not at this moment. I hope that more appropriate time will come.

Below I allowed myself to post some screenshots from backend and mobile part of this application.

Dashboard

Markers
OSM Upload
OSM Projects
HeatMap


Home
Settings
Transport Type
First marker
Multiple markers
Daily route
Settings


Reference :
[1] GitHub TrafficCity Backend
[2] GitHub TrafficCity Android
[3] BIHAPI

Atom RSS Parser Android

by GarciaPL on Wednesday, 21 January 2015

One of my Android applications requires to fetch and process external RSS resource. My first thought was that I should use very useful and well documented library called ROME [1]. Unfortunately I had some difficulties using this library because of there is a lack of java.beans package in Android's Java API implementation [2]. Of course you can fix this issue by installing some missing packages, but I was looking for some out-of-box solution. Finally, I found library called Simple Feed Parser [3]. It may for some of you be quite outdated (last commit was 4 years ago) and I found that there is a some issue with accessing date of single RSS entry, but it has very simple implementation, it is compatible with Android SDKs and it does not require any further library dependencies! Below you can find some example usage of this library in Java.

import com.ernieyu.feedparser.Feed;
import com.ernieyu.feedparser.FeedException;
import com.ernieyu.feedparser.FeedParser;
import com.ernieyu.feedparser.FeedParserFactory;
import com.ernieyu.feedparser.Item;

try {
                InputStream inputstream = new URL("http://rss.android.com/rss).openStream();
                FeedParser parser = FeedParserFactory.newParser();
                Feed feed = parser.parse(inputstream);
                List itemList = feed.getItemList();
                for (Item item : itemList) {
                    logger.info("Title : " + item.getTitle());
                    logger.info("Item : " + item.getLink());
                    logger.info("Description : " + item.getDescription());
                    logger.info("Date : " + item.getPubDate()); //might be null
                }
            } catch (IOException e) {
                logger.info("IOException : " + e.getMessage());
            } catch (FeedException e) {
                logger.info("FeedException : " + e.getMessage());
            }

References :  [1] ROME - All feeds lead to Rome! [2] Java.Beans on Android [3] Simple Feed Parser

Android Debug Keystore

by GarciaPL on Tuesday, 23 December 2014

For some of you I have this very useful command line for getting Android Debug Key which can be used for signing Android applications.

keytool -keystore /home/lukasz/.android/debug.keystore -v -list -alias androiddebugkey -storepass android -keypass android

After executing this command you will some something like that :


Alias name: androiddebugkey
Creation date: 2014-12-18
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 32435620
Valid from: Thu Dec 18 21:04:11 CET 2014 until: Sat Dec 10 21:04:11 CET 2044
Certificate fingerprints:
  MD5:  XXX
  SHA1: XXX
  SHA256: XXX
  Signature algorithm name: SHA256withRSA
  Version: 3

Extensions: 

#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 20 B4 60 1E 46 B5 AD B0   45 49 93 48 C2 D6 0C BF   .`.F...EI.H....
0010: 9C CD 8D 02                                        ....
]
]
Information under SHA1 can be used to signing Android apps. More information about signing Android apps you can find under this link Developer.android.com - App Signing.

ADB Not Responding in Intellij IDEA

by GarciaPL on Sunday, 21 December 2014

When you get this message - "ADB not responding. You can wait more or kill adb ..." just use this command :

fuser 5037/tcp

and after executing that command you will receive some PID (if your adb is still running) :

sudo kill -9 PID

Oracle DB 11g Errors Guide

by GarciaPL on Tuesday, 15 July 2014

I would like only to announce that I have created a small application in Android called Oracle DB 11g Errors Guide. This application helps you as a developer or administrator of Oracle ® Database 11g Release 1 find solutions of problems which you are faced with during your work. Each error message contains the message statement, an explanation of the probable causes and a recommended action.

More information about Oracle ® Database 11g Release 1 Error Messages you can find under hyperlink - Oracle® Database Error Messages 11g Release 1 (11.1) Documentation

Hyperlink to Google Play Store - Google Play Store GarciaPL