English 中文(简体)
• 如何在地位上公布最新状况。 甲型六氯环己烷
原标题:How to post the status updates in the Status.Net in android using the yamba-8 tutorial

实际上,我正面临着安乐斯的问题。 我正在制作一个与称作“地位”的Twitter相连接的申请。 净额 我在该网站上用我自己的用户名和密码设立了一个账户。 现在我提出的申请与这一状况有关。 网上网址。 最初,这一和甲状腺应用是从一个称为“学习”的学习和roid网站中选取的,我从这个网站下载源代码。 我正在创建我自己的版本,具体指明了不同的APICES,作为农场新闻.aaditech.com/api(最初的APIC根是

YambaApplication.java

package com.marakana.yamba8;

import java.util.List;

import winterwell.jtwitter.Twitter;
import winterwell.jtwitter.Twitter.Status;
import android.app.Application;
import android.content.ContentValues;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;

public class YambaApplication extends Application implements
OnSharedPreferenceChangeListener {
private static final String TAG = YambaApplication.class.getSimpleName();
public static final String LOCATION_PROVIDER_NONE = "NONE";
public static final long INTERVAL_NEVER = 0;
public Twitter twitter;
private SharedPreferences prefs;
private StatusData statusData;
private boolean serviceRunning;
private boolean inTimeline;

@Override
public void onCreate() {
super.onCreate();
this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
this.prefs.registerOnSharedPreferenceChangeListener(this);
this.statusData = new StatusData(this);
Log.i(TAG, "Application started");
}

public synchronized Twitter getTwitter() {
 if (this.twitter == null) {
   String username = this.prefs.getString("username", null);
   String password = this.prefs.getString("password", null);
   //String url = this.prefs.getString("url",
   //  "http://yamba.marakana.com/api");
   String url = this.prefs.getString("url",
   "http://farmnews.aaditech.com/index.php/api"); //1
   //String url = this.prefs.getString("url",
   //"http://identi.ca/api");
   //String url = this.prefs.getString("url",
   //"http://farmnews.aaditech.com");

    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)
      && !TextUtils.isEmpty(url)) {
      this.twitter = new Twitter(username, password);
      this.twitter.setAPIRootUrl(url);
    }
  }
  return this.twitter;
}

 public boolean startOnBoot() {
   return this.prefs.getBoolean("startOnBoot", false);
 }

 public StatusData getStatusData() {
   return statusData;
 }

  public synchronized int fetchStatusUpdates() {
    Log.d(TAG, "Fetching status updates");
    Twitter twitter = this.getTwitter();
    if (twitter == null) {
    Log.d(TAG, "Twitter connection info not initialized");
    return 0;
  }
  try {
    List<Status> statusUpdates = twitter.getFriendsTimeline();
    long latestStatusCreatedAtTime = this.getStatusData()
      .getLatestStatusCreatedAtTime();
    int count = 0;
    ContentValues values = new ContentValues();
    for (Status status : statusUpdates) {
      values.put(StatusData.C_ID, status.getId());
      long createdAt = status.getCreatedAt().getTime();
      values.put(StatusData.C_CREATED_AT, createdAt);
      values.put(StatusData.C_TEXT, status.getText());
      values.put(StatusData.C_USER, status.getUser().getName());
      Log.d(TAG, "Got update with id " + status.getId() + ". Saving");
      this.getStatusData().insertOrIgnore(values);
      if (latestStatusCreatedAtTime < createdAt) {
       count++;
      }
     }
    Log.d(TAG, count > 0 ? "Got " + count + " status updates"
      : "No new status updates");
    return count;
    } catch (Exception e) {
    Log.e(TAG, "Failed to fetch status updates", e);
    return 0;
   }
 }

  public synchronized void onSharedPreferenceChanged(
    SharedPreferences sharedPreferences, String key) {
    this.twitter = null;
  }

  public boolean isServiceRunning() {
     return serviceRunning;
  }

  public void setServiceRunning(boolean serviceRunning) {
    this.serviceRunning = serviceRunning;
  }

  public boolean isInTimeline() {
     return inTimeline;
  }

  public void setInTimeline(boolean inTimeline) {
     this.inTimeline = inTimeline;
  }

  public String getProvider() {
     return prefs.getString("provider", LOCATION_PROVIDER_NONE);
  }

  public long getInterval() {
     // For some reason storing interval as long doesn t work
     return Long.parseLong(prefs.getString("interval", "0"));
  }

  @Override
  public void onTerminate() {
  super.onTerminate();
  this.statusData.close();
  Log.i(TAG, "Application terminated");
  }
}

DDMSlogCat

    10-28 00:36:04.964: ERROR/YambaApplication(844): Failed to fetch status updates
10-28 00:36:04.964: ERROR/YambaApplication(844): winterwell.jtwitter.TwitterException: org.json.JSONException: No value for profile_background_color
10-28 00:36:04.964: ERROR/YambaApplication(844):     at winterwell.jtwitter.Twitter$User.<init>(Twitter.java:693)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at winterwell.jtwitter.Twitter$Status.<init>(Twitter.java:464)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at winterwell.jtwitter.Twitter$Status.getStatuses(Twitter.java:342)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at winterwell.jtwitter.Twitter.getStatuses(Twitter.java:1691)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at winterwell.jtwitter.Twitter.getFriendsTimeline(Twitter.java:1454)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at com.marakana.yamba8.YambaApplication.fetchStatusUpdates(YambaApplication.java:73)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at com.marakana.yamba8.UpdaterService.onHandleIntent(UpdaterService.java:35)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at android.os.Looper.loop(Looper.java:123)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at android.os.HandlerThread.run(HandlerThread.java:60)
10-28 00:36:04.964: ERROR/YambaApplication(844): Caused by: org.json.JSONException: No value for profile_background_color
10-28 00:36:04.964: ERROR/YambaApplication(844):     at org.json.JSONObject.get(JSONObject.java:354)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at org.json.JSONObject.getString(JSONObject.java:510)
10-28 00:36:04.964: ERROR/YambaApplication(844):     at winterwell.jtwitter.Twitter$User.<init>(Twitter.java:660)
10-28 00:36:04.964: ERROR/YambaApplication(844):     ... 10 more

http://identi.ca/api”rel=“nofollow”

Please help me out
Regards and Thanks
Sohaib Rahman

最佳回答
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签