How to implement two application classes in my manifest - java

Lets say i have a listview as my main activity.On clicking an item it opens up a second activity.On clicking a button it opens a custom listview using volley library from this tutorial if you are following(http://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/)
However on clicking the button in the second activity to open my listview with volley,my app stops.
The problem i figured started in the manifest as i'll post below.
I have two Application classes as i am using Parse push notification library.But however only one application can be declared to open on startup in the manifest.So i implemented the answer on this question(how to handle multiple application classes in android) .It was after this that my app kept stopping when opening the third activity.
So please help me achieve this.Thanks in advance.
Manifest snippet
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stevekamau.snapt"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="com.stevekamau.snapt.ParseApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
..............</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
</manifest>
I modified the AppController class from here(http://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/ ) to extend ParseApplication
public class AppController extends ParseApplication {
public static final String TAG = AppController.class.getSimpleName();
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private static AppController mInstance;
#Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance() {
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public ImageLoader getImageLoader() {
getRequestQueue();
if (mImageLoader == null) {
mImageLoader = new ImageLoader(this.mRequestQueue,
new LruBitmapCache());
}
return this.mImageLoader;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
// set the default tag if tag is empty
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
}
If you need more code please let me know.
log cat:
11-21 16:20:29.916: E/Trace(26640): error opening trace file: No such file or directory (2)
11-21 16:20:29.936: W/dalvikvm(26640): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
11-21 16:20:30.046: W/System.err(26640): Invalid int: ""
11-21 16:20:30.386: I/Adreno200-EGL(26640): <qeglDrvAPI_eglInitialize:299>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.01.21.010_msm8625_JB_REL_2.0.3_Merge_release_AU (Merge)
11-21 16:20:30.386: I/Adreno200-EGL(26640): Build Date: 10/26/12 Fri
11-21 16:20:30.386: I/Adreno200-EGL(26640): Local Branch:
11-21 16:20:30.386: I/Adreno200-EGL(26640): Remote Branch: quic/jb_rel_2.0.3
11-21 16:20:30.386: I/Adreno200-EGL(26640): Local Patches: NONE
11-21 16:20:30.386: I/Adreno200-EGL(26640): Reconstruct Branch: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.01.21.010 + NOTHING
11-21 16:20:37.636: W/dalvikvm(26640): threadid=1: thread exiting with uncaught exception (group=0x40e08438)
11-21 16:20:49.016: E/Trace(26711): error opening trace file: No such file or directory (2)
11-21 16:20:49.036: W/dalvikvm(26711): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
11-21 16:20:49.096: W/System.err(26711): Invalid int: ""

Related

Permission denied error when uploading image to server

In my app I'm trying to take a picture and send it over to the server coded as a String when I run it, I am able to take the picture but as soon as I click ok the app crashes and I get the following error:
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/Pictures/test123.jpeg: open failed: EACCES (Permission denied)
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: info.androidhive.loginandregistration, PID: 8775
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
at info.androidhive.loginandregistration.activity.ImageActivity$Encode_image.doInBackground(ImageActivity.java:86)
at info.androidhive.loginandregistration.activity.ImageActivity$Encode_image.doInBackground(ImageActivity.java:79)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
Heres my code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.androidhive.loginandregistration"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.Camera" android:required="true"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="info.androidhive.loginandregistration.app.AppController"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".activity.LoginActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.RegisterActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activity.MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop" />
<activity
android:name=".activity.test"
android:label="#string/app_name"
android:launchMode="singleTop" />
<activity
android:name=".activity.SearchActivity"
android:label="MY SICK APP"
android:launchMode="singleTop" />
<activity
android:name=".activity.ImageActivity"
android:label="MY SICK APP"
android:launchMode="singleTop"
android:largeHeap="true"/>
</application>
</manifest>
-
public class ImageActivity extends Activity{
final String URL = "linktophpfile";
private Button button;
private String coded_string, name;
private Bitmap bitmap;
private File file;
private Uri uri;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image_main);
button = (Button) findViewById(R.id.bt_main);
button.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick (View view){
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
getUri();
i.putExtra(MediaStore.EXTRA_OUTPUT,uri);
startActivityForResult(i,5);
}
});
}
public void getUri() {
String name = "test123.jpeg";
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+ file.separator + name);
uri = Uri.fromFile(file);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==5 && resultCode== RESULT_OK){
new Encode_image().execute();
}
}
private class Encode_image extends AsyncTask<Void,Void,Void> {
#Override
protected Void doInBackground(Void... voids) {
bitmap = BitmapFactory.decodeFile(uri.getPath());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG,100,stream);
bitmap.recycle();
byte[] array = stream.toByteArray();
coded_string = Base64.encodeToString(array,0);
return null;
}
#Override
protected void onPostExecute(Void aVoid) {
makeRequest();
}
}
private void makeRequest() {
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest request = new StringRequest(Request.Method.POST,URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
}
}, new Response.ErrorListener(){
#Override
public void onErrorResponse(VolleyError error){
}
}){
#Override
protected Map<String, String> getParams() throws AuthFailureError{
HashMap<String, String> map = new HashMap<>();
map.put("coded_String", coded_string);
map.put("image_name", name);
return map;
}
};
queue.add(request);
}
}
php code:
<?php
header('Content-type : bitmap; charset=utf-8');
if(isset($_POST["encoded_string"])){
$encoded_string = $_POST["encoded_string"];
$image_name = $_POST["image_name"];
$decoded_string = base64_decode($encoded_string);
$path = 'images/'.$image_name;
$file = fopen($path, 'wb');
$is_written = fwrite($file, $decoded_string);
fclose($file);
if($is_written > 0) {
$connection = mysqli_connect('localhost', 'username', 'password','dbname');
$query = "INSERT INTO images(name,path) values('$image_name','$path');";
$result = mysqli_query($connection, $query) ;
if($result){
echo "success";
}else{
echo "failed";
}
mysqli_close($connection);
}
}
?>
Any ideas of what could be wrong? thanks
Make sure you have
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Declared in your manifest.xml file
1 check your app's permission states in phone settings.
2 Check this photo's real uri in debug mode.

How to save data on parse after login using parse?

I have used parse.com for login and registration, and successfully registration details are begin saved on parse.com, and login works fine too. But I want to make a form after Login. In Which , When user login into app, he will see a form to fill up, and again details provided by him should be stored inside parse.com .
Advance Thanks if great response...
Logcat
11-10 13:04:05.798 2764-2773/? E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'release' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:180)
at android.drm.DrmManagerClient.<init>(DrmManagerClient.java:258)
at com.google.ccc.abuse.droidguard.DroidGuard.runNative(Native Method)
at com.google.ccc.abuse.droidguard.DroidGuard.run(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.android.gms.droidguard.d.f.a(SourceFile:34)
at com.google.android.gms.droidguard.d.l.a(SourceFile:71)
at com.google.android.gms.droidguard.d.k.a(SourceFile:92)
at com.google.android.gms.droidguard.d.k.a(SourceFile:68)
at com.google.android.gms.droidguard.l.a(SourceFile:249)
at com.google.android.gms.droidguard.c.t.onTransact(SourceFile:60)
at android.os.Binder.execTransact(Binder.java:453)
I did something as shown below, but when user enters his name, it says form error..
Form.java
public class Form extends Activity {
// Declare Variables
Button send;
String nametxt;
EditText name;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.formfilluo);
name = (EditText) findViewById(R.id.name);
send = (Button) findViewById(R.id.send);
send.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
nametxt = name.getText().toString();
if (nametxt.equals("")) {
Toast.makeText(getApplicationContext(),
"Please complete the reservation form",
Toast.LENGTH_LONG).show();
} else {
ParseObject dataObject = new ParseObject("User");
dataObject.put("name", name);
//User is classname created on parse.com
// name is a column in the class"User"
dataObject.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
// Show a simple Toast message upon successful registration
Intent iSuccess = new Intent(getApplicationContext(), SubmitSuccess.class);
startActivity(iSuccess);
Toast.makeText(getApplicationContext(),
"Successfully Reserved your table",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Form Error", Toast.LENGTH_LONG)
.show();
name.setText("");
}
}
});
}
}
});
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="world.yakuza.krishnavanshi.dev15_10_2015"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="ParseApplication"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme"
android:label="#string/app_name" >
<activity
android:name=".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>
<activity android:name=".LoginSignupActivity" >
</activity>
<activity android:name=".Welcome" >
</activity>
<activity android:name=".Offers" >
</activity>
<activity android:name=".MainForm" >
</activity>
<activity android:name=".Form" >
</activity>
<activity android:name=".SubmitSuccess" >
</activity>
</application>
</manifest>
form_layout
What i changed to save data is given below:
SignUp to SaveData

Null pointer exception - Service SMS with Text To Speech

I want to make an application with can say a text with a TextToSpeach when I receive a SMS.
For that I have a Service, a Receiver and a class SaidThis.
See my code :
My service :
package fr.dabernat.smsreceiver;
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Service extends IntentService {
private Handler handler;
public static String text;
public Service() {
super("Service");
}
#Override
public void onCreate() {
super.onCreate();
handler = new Handler();
}
#Override
public void onDestroy() {
super.onDestroy();
}
#Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
if (!extras.isEmpty()) {
SaidThis test = new SaidThis();
test.SpeakText();
//showNotification();
//SaidThis test = new SaidThis(this);
//test.text("J'ai honte de moi");
}
Receiver.completeWakefulIntent(intent);
}
}
My Receiver :
package fr.dabernat.smsreceiver;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
public class Receiver extends WakefulBroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// Explicitly specify that Service will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
Service.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
My class SaidThis :
package fr.dabernat.smsreceiver;
import android.speech.tts.TextToSpeech;
import java.util.Locale;
/**
* Created by Damien on 19/09/2014.
*/
public class SaidThis extends Service implements TextToSpeech.OnInitListener, TextToSpeech.OnUtteranceCompletedListener {
TextToSpeech tts;
#Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
tts.setLanguage(Locale.FRANCE);
}
}
#Override
public void onUtteranceCompleted(String s) {
stopSelf();
}
public void SpeakText(){
tts.speak(text,TextToSpeech.QUEUE_FLUSH, null);
}
}
My Android Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.dabernat.smsreceiver" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
<receiver
android:name=".Receiver" >
<intent-filter>
<!-- A CHANGER POUR "ECOUTER" UN AUTRE BROADCAST -->
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<service android:name=".Service" />
</application>
</manifest>
Errors :
10-08 10:44:51.980 1371-1371/fr.dabernat.smsreceiver E/dalvikvm﹕ >>>>> Normal User
10-08 10:44:51.980 1371-1371/fr.dabernat.smsreceiver E/dalvikvm﹕ >>>>> fr.dabernat.smsreceiver [ userId:0 | appId:10309 ]
10-08 10:44:52.080 1371-1412/fr.dabernat.smsreceiver E/AndroidRuntime﹕ FATAL EXCEPTION: IntentService[Service]
Process: fr.dabernat.smsreceiver, PID: 1371
java.lang.NullPointerException
at fr.dabernat.smsreceiver.SaidThis.SpeakText(SaidThis.java:34)
at fr.dabernat.smsreceiver.Service.onHandleIntent(Service.java:36)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.os.HandlerThread.run(HandlerThread.java:61)
I think the problem come from my service but I don't know where.
I try to find some answer on the web before but I don't find any solution to my problem.
Your tts object is not initialized anywhere, therefore it's null.
You have to initialize it: tts = new TextToSpeech() somewhere, before you use it in your SpeakText() method.
I assume onInit() method would be a good fit for initializing your object.

Ad isn't loading

I followed the google tutorial on interstitial ads, but whenever I try to display my ad it never is loaded. I've tried to use AdListener instead of interstitial.isLoaded, but still the same result. I've also given the ad over 2 minutes to load a couple times, so something must be wrong.
I am using an AVD, could that be the problem? It can connect to the Internet just fine when I use the browser though.
removed an incorrect link
androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.JrodManU.LaserJumper.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/GdxTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".AndroidLauncher"
android:clearTaskOnLaunch="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
AndroidLauncher
package com.JrodManU.LaserJumper.android;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.android.gms.ads.*;
import com.JrodManU.LaserJumper.GameEventListener;
import com.JrodManU.LaserJumper.LaserJumper;
public class AndroidLauncher extends AndroidApplication implements GameEventListener {
private InterstitialAd interstitial;
boolean showed = false;
boolean loaded = false;
#Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new LaserJumper(this), config);
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("******");
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//.addTestDevice(testDeviceId)
.build();
interstitial.loadAd(adRequest);
interstitial.setAdListener(new AdListener(){
public void onAdLoaded(){
loaded = true;
}
});
}
public boolean displayInterstitial() {
this.runOnUiThread(new Runnable() {
#Override
public void run() {
if(loaded) {
interstitial.show();
showed = true;
} else {
System.out.println("failed"); //Always prints failed
showed = false;
}
}
});
return showed;
}
}
If you got this error:
could not find com.google.android.gms.ads.AdActivity, please make sure
it is declared in AndroidManifest.xml
Then adding this activity declaration within the <application> tag in your Manifest should fix it:
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

Android - ClassNotFoundException (TwitterAPI)

Okay so I've been messing around with the Twitter API, and all of a sudden I've started to get the ClassNotFoundException error code when I try and enter the Activity which has my login box to sign into Twitter.
Here's the error code.
2398-2398/josh.com.twitterapi E/dalvikvm﹕ Could not find class 'josh.com.twitterapi.LoginActivity', referenced from method josh.com.twitterapi.NavigationDrawerFragment.selectItem
07-05 02:19:30.138 2398-2398/josh.com.twitterapi E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: josh.com.twitterapi.LoginActivity
at josh.com.twitterapi.NavigationDrawerFragment.selectItem(NavigationDrawerFragment.java:204)
at josh.com.twitterapi.NavigationDrawerFragment.access$000(NavigationDrawerFragment.java:32)
at josh.com.twitterapi.NavigationDrawerFragment$1.onItemClick(NavigationDrawerFragment.java:99)
at android.widget.AdapterView.performItemClick(AdapterView.java:301)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3071)
at android.widget.AbsListView$1.run(AbsListView.java:3973)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
07-05 02:21:03.973 3223-3223/josh.com.twitterapi E/dalvikvm﹕ Could not find class 'josh.com.twitterapi.LoginActivity', referenced from method josh.com.twitterapi.NavigationDrawerFragment.selectItem
This is my LoginActivity.java.
package josh.com.socialme;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import com.codepath.oauth.OAuthLoginActivity;
public class LoginActivity extends OAuthLoginActivity<TwitterClient> {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
// Inflate the menu; this adds items to the action bar if it is present.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
// OAuth authenticated successfully, launch primary authenticated activity
// i.e Display application "homepage"
#Override
public void onLoginSuccess() {
// Intent i = new Intent(this, PhotosActivity.class);
// startActivity(i);
}
// OAuth authentication flow failed, handle the error
// i.e Display an error dialog or toast
#Override
public void onLoginFailure(Exception e) {
e.printStackTrace();
}
// Click handler method for the button used to start OAuth flow
// Uses the client to initiate OAuth authorization
// This should be tied to a button used to login
public void loginToRest(View view) {
getClient().connect();
}
}
This is my AndroidManifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="josh.com.socialme" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.DarkActionBar" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<activity
android:name=".Hub"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Feed"
android:label="#string/title_activity_feed" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
And this is my method I use to get to the activity.
private void selectItem(int position) {
// Handle Navigation Options
Intent intent;
switch (position) {
case 1:
intent = new Intent(getActivity(), Feed.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getActivity().startActivity(intent);
break;
case 2:
intent = new Intent(getActivity(), LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getActivity().startActivity(intent);
break;
}
}
I would greatly appreciate it if someone could point me towards the right direction.
Kind regards,
Josh
(AndroidManifest.xml as requested)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="josh.com.socialme" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.DarkActionBar" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<activity
android:name=".Hub"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Feed"
android:label="#string/title_activity_feed" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_login_activity" >
</activity>
</application>
</manifest>

Categories