Pages

April 27, 2014

[Solution] Twitter oauth.signpost.exception.OAuthCommunicationException: Service provider responded in error: 403 (Forbidden)

I was searching solution for the error,
"oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Service provider responded in error: 403 (Forbidden)" in android social sharing app that require twitter login. Finally found the problem with oauth urls.

Here's how to solve it.

Change,
public static final String REQUEST_URL = "http://api.twitter.com/oauth/request_token";
public static final String ACCESS_URL = "http://api.twitter.com/oauth/access_token";
public static final String AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize
 To
public static final String REQUEST_URL = "https://api.twitter.com/oauth/request_token";
public static final String ACCESS_URL = "https://api.twitter.com/oauth/access_token";
public static final String AUTHORIZE_URL = "https://api.twitter.com/oauth/authorize";
Summary : change http to https and error got fixed.
Hope this helps! 

April 26, 2014

Essential Webmaster Tools to Setup After Launching Your New Website


Google Analytics

  • Track Pageviews
  • Track Events
  • Realtime Visitors
  • Keywords
  • Outbound Clicks
  • Measurable (Send Enquiry, Get Quote)

Google Webmaster Tool

  • Crawling
  • Submit Sitemap
  • Search Queries (Position, Keywords, CTR, Impression)
  • Crawling Errors
  • Robots.txt
  • Inbound Links

Bing Webmaster Tool

  • For Yahoo & Bing

A/B Testing Analytics

OR
  • Test headlines
  • Call to Action Button/Text
  • Links
  • Testimonials

[Solution] UTF-8 Gujarati Langauge Text Display Problem in Android

Gujarati Text (in UTF-8) in your JSON Response : ભારત - સર્વ શ્રેષ્ટ દેશ છે.

Steps to set it correctly in Android Textview:

  1. Copy Gujarati font in assest project directory
  2. Apply Gujarati font to textview, follow this steps.
  3. textView.setText(Html.fromHtml("YOUR UTF-8 Gujarati String HERE"));
This simple steps will display your all UTF-8 language text in android. Follow same steps for Punjabi, Tamil, Kannad, Bengali, Marathi language. 

Hope this helps!

April 16, 2014

Android Custom Crash Reporting Dialog & Reporting Data


MainApplication
package com.yourpkg;

import android.app.Application;
import android.content.Intent;
import android.util.Log;

public class MainApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler(this));
    }

    public class TopExceptionHandler implements Thread.UncaughtExceptionHandler {

        private Application app = null;
        
        public TopExceptionHandler(Application app) {
            Thread.setDefaultUncaughtExceptionHandler(this);
            this.app = app;
        }

        public void uncaughtException(Thread t, Throwable e) {
            
            Log.v("tagas","uncaught exception ");
            
            StackTraceElement[] arr = e.getStackTrace();
            String report = e.toString() + "\n\n";
            report += "--------- Stack trace ---------\n\n";
            for (int i = 0; i < arr.length; i++) {
                report += "    " + arr[i].toString() + "\n";
            }
            report += "-------------------------------\n\n";

            // If the exception was thrown in a background thread inside
            // AsyncTask, then the actual exception can be found with getCause
            report += "--------- Cause ---------\n\n";
            Throwable cause = e.getCause();
            if (cause != null) {
                report += cause.toString() + "\n\n";
                arr = cause.getStackTrace();
                for (int i = 0; i < arr.length; i++) {
                    report += "    " + arr[i].toString() + "\n";
                }
            }
            report += "-------------------------------\n\n";

            final String reportText=report;

            Log.d("atag","report["+report+"]");

            notifyDialog(reportText);
            android.os.Process.killProcess(android.os.Process.myPid());
            System.exit(1);
           
        }
        
        void notifyDialog(String reportText) {
            try {
                Log.d("atg", "Creating Dialog for " + reportText);
                Intent dialogIntent = new Intent(app.getApplicationContext(), CrashReportDialog.class);
                dialogIntent.putExtra("CRASH_LOG", reportText);
                dialogIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                app.getApplicationContext().startActivity(dialogIntent);
                
                
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}


CrashReportDialog

package com.example.exceptionhandlr;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class CrashReportDialog extends Activity implements OnClickListener {

    String VersionName;
    String PackageName;
    String FilePath;
    String PhoneModel;
    String AndroidVersion;
    String Board;
    String Brand;
    String Device;
    String Display;
    String FingerPrint;
    String Host;
    String ID;
    String Manufacturer;
    String Model;
    String Product;
    String Tags;
    long Time;
    String Type;
    String User;
    
    Context mContext;
    String crashLog="TEXT";
    private Button buttonSubmitReport;
    private Button buttonSubmitCancle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.crashreport_activity);

        mContext = this;

        if (getIntent().getStringExtra("CRASH_LOG") != null) {
            crashLog = getIntent().getStringExtra("CRASH_LOG");
        }
        // showDialog(text);
        crashLog += CreateInformationString();

        ((TextView) findViewById(R.id.text1)).setText(crashLog);
        buttonSubmitReport = (Button) findViewById(R.id.buttonSumbmitReport);
        buttonSubmitCancle = (Button) findViewById(R.id.buttonCancleReport);
        buttonSubmitReport.setOnClickListener(this);
        buttonSubmitCancle.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.buttonSumbmitReport:
            sendEmailErrorReport(crashLog);
            break;

        case R.id.buttonCancleReport:
            restartApp();
            break;

        default:
            break;
        }
    }

    public void sendEmailErrorReport(String bodyContent) {

        final Intent emailIntent = new Intent(
                android.content.Intent.ACTION_SEND);

        // open with email supported apps
        emailIntent.setType("message/rfc822");

        // support mail from string.xml
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                new String[] { getString(R.string.support_email) });

        // AppName + Subject text from string.xml
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                getString(R.string.app_name)+getString(R.string.support_crash_subj));

        // Inital body text from string.xml + crash log 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                getString(R.string.support_crash_body) + bodyContent);

        finish();
        
        startActivity(Intent.createChooser(emailIntent, "Send Report"));

        // restart app
        // restartApp();
        
    }

    public void restartApp() {
        Intent i = getBaseContext().getPackageManager()
                .getLaunchIntentForPackage(getBaseContext().getPackageName());
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        
        finish();
        startActivity(i);
    }
    

    void RecoltInformations(Context context) {
        try {
            PackageManager pm = context.getPackageManager();
            PackageInfo pi;
            // Version
            pi = pm.getPackageInfo(context.getPackageName(), 0);
            VersionName = pi.versionName;
            // Package name
            PackageName = pi.packageName;
            // Device model
            PhoneModel = android.os.Build.MODEL;
            // Android version
            AndroidVersion = android.os.Build.VERSION.RELEASE;

            Board = android.os.Build.BOARD;
            Brand = android.os.Build.BRAND;
            Device = android.os.Build.DEVICE;
            Display = android.os.Build.DISPLAY;
            FingerPrint = android.os.Build.FINGERPRINT;
            Host = android.os.Build.HOST;
            ID = android.os.Build.ID;
            Model = android.os.Build.MODEL;
            Product = android.os.Build.PRODUCT;
            Tags = android.os.Build.TAGS;
            Time = android.os.Build.TIME;
            Type = android.os.Build.TYPE;
            User = android.os.Build.USER;

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String CreateInformationString() {
        RecoltInformations(mContext);

        String ReturnVal = "";
        ReturnVal += "Version : " + VersionName;
        ReturnVal += "\n";
        ReturnVal += "Package : " + PackageName;
        ReturnVal += "\n";
        ReturnVal += "FilePath : " + FilePath;
        ReturnVal += "\n";
        ReturnVal += "Phone Model" + PhoneModel;
        ReturnVal += "\n";
        ReturnVal += "Android Version : " + AndroidVersion;
        ReturnVal += "\n";
        ReturnVal += "Board : " + Board;
        ReturnVal += "\n";
        ReturnVal += "Brand : " + Brand;
        ReturnVal += "\n";
        ReturnVal += "Device : " + Device;
        ReturnVal += "\n";
        ReturnVal += "Display : " + Display;
        ReturnVal += "\n";
        ReturnVal += "Finger Print : " + FingerPrint;
        ReturnVal += "\n";
        ReturnVal += "Host : " + Host;
        ReturnVal += "\n";
        ReturnVal += "ID : " + ID;
        ReturnVal += "\n";
        ReturnVal += "Model : " + Model;
        ReturnVal += "\n";
        ReturnVal += "Product : " + Product;
        ReturnVal += "\n";
        ReturnVal += "Tags : " + Tags;
        ReturnVal += "\n";
        ReturnVal += "Time : " + Time;
        ReturnVal += "\n";
        ReturnVal += "Type : " + Type;
        ReturnVal += "\n";
        ReturnVal += "User : " + User;
        ReturnVal += "\n";
        // ReturnVal += "Total Internal memory : " +
        // getTotalInternalMemorySize();
        // ReturnVal += "\n";
        // ReturnVal += "Available Internal memory : "
        // + getAvailableInternalMemorySize();
        ReturnVal += "\n";

        return ReturnVal;
    }

}


MainActivity

package com.example.exceptionhandlr;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        
        findViewById(R.id.buttonCreateCrash).setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {

                // DIVIDE by ZERO Error
                // THIS LINE CAUSE EXCEPTION
                int i=55/0;
            }
        });
        
    }
}

April 11, 2014

Why Web Based Software As A Service is Getting Popularity These Days?

Software As A Service (SAAS ) is now-a-days becoming too much viral in the software industry as it is very convenient to vendors as well as users. Many of us is not knowing what is software as a service, How it works and How it can benefit us in our work ? At SoftwareSuggest, we often get these questions from our users.

Software as a service is nothing but the software delivery method which provides access to the software and all its functionalities from anywhere and on any device remotely. Software as a Service allows organizations to access and manage their data at low costs than buying a licensed software as SAAS is mostly based on a monthly subscriptions. As software is hosted remotely, organizations don't have any additional expenses on hardware like servers. Software as a service makes organizations free from setting up and installation of software, backing up data and maintenance costs and problems of hardware.

In Software as a service, software and its associated data is hosted on the cloud than it is accessed by users using thin client via web browser on any device. Below are common reasons why web based software as a service is getting popular these days and why organizations should switch to SAAS -

  • Fast setup and installation
  • Non-Technical Configuration
  • Little IT involvement.
  • Integrated MDM Support
  • Upgrades included.
  • Frequent New Features.
  • No Hardware Costs.
  • Subscription Billing.