0

I am learning to develop services in Android and following the Marakana Yamba example.

I have created the UpdaterService which pulls the tweets and regular interval and a RefreshService which will pull the tweets when selected.

For pulling the tweets the code is same in both the services but in RefreshService I am getting below error while UpdateService is running withput any error:

02-19 14:31:41.359 1323-1345/com.tutorial.yamba.yamba W/System.err﹕ winterwell.jtwitter.TwitterException: org.json.JSONException: Value (JSONArray.java:96) 02-19 14:31:41.379 1323-1345/com.tutorial.yamba.yamba W/System.err﹕ at org.json.JSONArray.(JSONArray.java:108) 02-19 14:31:41.389 1323-1345/com.tutorial.yamba.yamba W/System.err﹕ at winterwell.jtwitter.Twitter$Status.getStatuses(Twitter.java:339) 02-19 14:31:41.389 1323-1345/com.tutorial.yamba.yamba W/System.err﹕ ... 7 more

Below is the RefreshService class

package com.tutorial.yamba.yamba;

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

import java.util.List;

import winterwell.jtwitter.Twitter;
import winterwell.jtwitter.Twitter.Status;
import winterwell.jtwitter.TwitterException;

public class RefreshService extends IntentService {

    static final String TAG = "RefreshService";
    Twitter twitter;

    public RefreshService() {
        super(TAG);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        twitter = new Twitter(someusername, somepassword);
        twitter.setAPIRootUrl("http://www.yamba.marakana.com/api");
        Log.d(TAG, "onCreate");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Log.d(TAG,"onhandleIntent enter");
        try {
            List<Status> timeline = twitter.getPublicTimeline();
            Log.d(TAG,timeline.size()+"");
            for (Status status : timeline)
            {
                Log.d(TAG, String.format("%s: %s", status.user.name, status.text));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy");
    }


}

Any help will be highly appreciated.

Thanks.

user3275095
  • 1,605
  • 4
  • 24
  • 36

1 Answers1

0

That error message looks like the server is returning an html error page. I think the Marakana server may have moved (or shut down).

Why not try working with Twitter directly? You need to use oauth for authentication, but otherwise the Marakana tutorial should be fine.

Or there is identi.ca, which can use name/password. But oauth is not so hard, and Twitter is more fun.

NB: Best to download the latest JTwitter from http://www.winterwell.com/software/jtwitter.php

Daniel Winterstein
  • 2,418
  • 1
  • 29
  • 41