The application crashes as soon as I press the settings button (set up in another layout:-). I am sharing only the relevant code here. What I want to do here is that I want to load prefs activity which has preferences setup. Any help will be highly appreciated.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.example.dummyproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".SignIn"
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=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.dummyproject.start_surfing" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Prefs"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.dummyproject.prefsettings" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".URIsettings"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.dummyproject.oldsettings" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Prefs.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://ift.tt/nIICcg" >
<EditTextPreference
android:title = "eText_ip"
android:key = "ipAddr"
android:summary="Enter the IP address of the webserver"
android:defaultValue="192.168.1.4"
/>
<EditTextPreference
android:title = "eText_port"
android:key = "portNum"
android:summary="Enter the port number on which the webserver is running"
android:defaultValue = "8080"
/>
<EditTextPreference
android:title="eText_location"
android:key="location"
android:summary = "Enter the name of .html/.php file that you want to run"
android:defaultValue="shaheer/traveller.php"
/>
Prefs.java
package com.example.dummyproject;
import android.os.Bundle;
import android.preference.PreferenceFragment;
public class Prefs extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
addPreferencesFromResource (R.xml.prefs);
}
}
SignIn.java
package com.example.dummyproject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class SignIn extends Activity {
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView (R.layout.app_login);
// com.example.dummyproject.settings
Button signInButton = (Button) findViewById (R.id.sign_up_btn);
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intOpenWebView = new Intent ("com.example.dummyproject.start_surfing");
startActivity (intOpenWebView);
}
});
Button settingsButton = (Button) findViewById (R.id.settings_btn);
settingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// THE APPLICATION CRASHES RIGHT HERE!
Intent intOpenWebView = new Intent ("com.example.dummyproject.prefsettings");
startActivity (intOpenWebView);
}
});
}
private int authenticate (String userName, String password) {
return 1;
}
}
No comments:
Post a Comment