I am creating an application for integration into social networks for Android. I can already post on Facebook, Twitter, and Linkedin. Now I need to integrate Flickr into the application. I could not find the right example of how to integrate flicker in an Android app.
My source codes are listed below:
This is the FlickrViewerActivity class:
public class FlickrViewerActivity extends Activity { public static final String CALLBACK_SCHEME = "flickrj-android-sample-oauth"; //$NON-NLS-1$ public static final String PREFS_NAME = "flickrj-android-sample-pref"; //$NON-NLS-1$ public static final String KEY_OAUTH_TOKEN = "flickrj-android-oauthToken"; //$NON-NLS-1$ public static final String KEY_TOKEN_SECRET = "flickrj-android-tokenSecret"; //$NON-NLS-1$ public static final String KEY_USER_NAME = "flickrj-android-userName"; //$NON-NLS-1$ public static final String KEY_USER_ID = "flickrj-android-userId"; //$NON-NLS-1$ private static final Logger logger = LoggerFactory.getLogger(FlickrjAndroidSampleActivity.class); private ListView listView; private TextView textUserTitle; private TextView textUserName; private TextView textUserId; private ImageView userIcon; private ImageButton refreshButton; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); this.textUserTitle = (TextView) this.findViewById(R.id.profilePageTitle); this.textUserName = (TextView) this.findViewById(R.id.userScreenName); this.textUserId = (TextView) this.findViewById(R.id.userId); this.userIcon = (ImageView) this.findViewById(R.id.userImage); this.listView = (ListView) this.findViewById(R.id.imageList); this.refreshButton = (ImageButton) this.findViewById(R.id.btnRefreshUserProfile); this.refreshButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { load(getOAuthToken()); } }); OAuth oauth = getOAuthToken(); if (oauth == null || oauth.getUser() == null) { OAuthTask task = new OAuthTask(this); task.execute(); } else { load(oauth); } } private void load(OAuth oauth) { if (oauth != null) { new LoadUserTask(this, userIcon).execute(oauth); new LoadPhotostreamTask(this, listView).execute(oauth); } } @Override public void onDestroy() { listView.setAdapter(null); super.onDestroy(); } /* (non-Javadoc) * @see android.app.Activity
OAuthTask Class:
public class OAuthTask extends AsyncTask<Void, Integer, String> { private static final Logger logger = LoggerFactory .getLogger(OAuthTask.class); private static final Uri OAUTH_CALLBACK_URI = Uri.parse(FlickrjAndroidSampleActivity.CALLBACK_SCHEME + "://oauth");
File Manifest :
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.flickr.test" android:versionCode="1" android:versionName="1.0" android:installLocation="preferExternal"> <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".FlickrViewerActivity" android:label="@string/title_activity_flickr_viewer" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="flickrj-android-sample-oauth" /> </intent-filter> </activity> </application> </manifest>
Main.xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:padding="@dimen/padding_medium" android:text="@string/hello_world" tools:context=".FlickrViewerActivity" /> </RelativeLayout>
I followed the tutorial at:
http://code.google.com/p/flickrj-android/wiki/HowToGuide4Android
Codes do not execute, I'm looking for a solution or sample source code for a project in Android with Flickr integration.
source share