I am trying to implement preferences using multiple screens. The action bar back button only returns to MainActivity even for sub preference screens. For example, I have a root preference screen and then a sub reference screen. The back button on the root preference screen goes back to the main activity as expected. But the back button on the sub reference screen also goes back to the main activity rather than the root preference screen. Below is a code dump because I'm not sure what I am doing wrong. Thanks.
Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.PreferencesTest">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SettingsActivity2"
android:label="#string/title_activity_settings2"
android:parentActivityName=".SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".SettingsActivity" />
</activity>
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".MainActivity"
android:theme="#style/AppTheme.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.kt
class MainActivity : AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?)
{
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
//Inflates settings menu button
override fun onCreateOptionsMenu(menu: Menu): Boolean
{
val inflater: MenuInflater = menuInflater
inflater.inflate(R.menu.settings_menu, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean
{
return when(item.itemId)
{
R.id.action_settings ->
{
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
true
}
else -> super.onOptionsItemSelected(item)
}
}
}
SettingsActivity.kt
class SettingsActivity : AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.settings_activity)
supportFragmentManager
.beginTransaction()
.replace(R.id.settings, SettingsFragment())
.commit()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
class SettingsFragment : PreferenceFragmentCompat()
{
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?)
{
setPreferencesFromResource(R.xml.root_preferences, rootKey)
}
}
}
SettingsActivity2.kt
class SettingsActivity2 : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.settings_activity)
supportFragmentManager
.beginTransaction()
.replace(R.id.settings, SettingsFragment())
.commit()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
class SettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.preferences2, rootKey)
}
}
}
res > menu > settings_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:title="Settings"
app:showAsAction="ifRoom" />
</menu>
res > xml > root_preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
android:fragment="com.example.PreferencesTest.SettingsActivity2$SettingsFragment"
android:title="Title"
android:summary="Summary">
<extra
android:name="name"
android:value="preferences2" />
</Preference>
</PreferenceScreen>
res > xml > preferences2.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditTextPreference
app:key="callNumber"
app:title="Call Number"
android:inputType="phone"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>
You need to override the default behavior of android.R.id.home to onBackPressed.
class SettingsActivity : AppCompatActivity() {
...
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
onBackPressed()
true
}
else -> super.onOptionsItemSelected(item)
}
}
...
Found a good complete example here https://github.com/googlearchive/android-preferences
Related
I Have a problem when I use a TabLayout on fragment. it is only one time performing by showing another fragment but after I click on other application part and then back to the fragment which is containing TabLayout, then it doesn't show TabLayout content.
My TabLayout Problem Ilustrate
class FavoritesFragment : Fragment() {
private var tabLayout: TabLayout? = null
private var viewPager: ViewPager? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_favorites, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
tabLayout = view.findViewById(R.id.tabs) as TabLayout
viewPager = view.findViewById(R.id.viewpager) as ViewPager
super.onViewCreated(view, savedInstanceState)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
viewPager!!.setAdapter(MyAdapter(fragmentManager))
tabLayout!!.post(Runnable { tabLayout!!.setupWithViewPager(viewPager) })
super.onActivityCreated(savedInstanceState)
}
private inner class MyAdapter(fm: FragmentManager?) : FragmentPagerAdapter(fm!!, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
private val int_items = 2
override fun getItem(position: Int): Fragment {
var fragment: Fragment? = null
when (position) {
0 -> fragment = MoviesFavoritesFragment()
1 -> fragment = TvSeriesFavoritesFragment()
}
return fragment!!
}
override fun getCount(): Int {
return int_items
}
override fun getPageTitle(position: Int): CharSequence? {
when (position) {
0 -> return "Movie Favorites"
1 -> return "Tv Series Favorites"
}
return null
}
}
}
and here my XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/material_blue_grey_800"
app:tabGravity="fill"
app:tabIndicatorColor="#color/colorPrimary"
app:tabSelectedTextColor="#color/white"
app:tabTextColor="#color/colorPrimary"
app:layout_constraintTop_toTopOf="parent"/>
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#id/tabs"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Most probably the bug is in here:
viewPager!!.setAdapter(MyAdapter(fragmentManager))
Try passing childFragmentManager there
My app to read incoming sms using broadcast receiver is working fine in many mobiles but not working in samsung j5 mobile. Can you give me proper solution for that problem.
My MainActivity.java is
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyReceiver.bindListener(new SmsListener.OTPListener() {
#Override
public void messageReceived(String messageText, String messageSender) {
Toast.makeText(MainActivity.this,"message is "+messageText+ " and sender is "+messageSender ,Toast.LENGTH_SHORT).show();
}
});
}
}
MyReceiver.java
public class MyReceiver extends BroadcastReceiver {
private static SmsListener.OTPListener mListener;
#Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
Bundle data = intent.getExtras();
Object[] pdus = new Object[0];
if(data != null)
{
pdus = (Object[]) data.get("pdus");
}
if(pdus != null)
{
for(Object pdu : pdus ){
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[])pdu);
String sender = smsMessage.getDisplayOriginatingAddress();
String messageBody = smsMessage.getMessageBody();
if (mListener!=null)
{
mListener.messageReceived(messageBody, sender);
break;
}
}
}
}
public static void bindListener(SmsListener.OTPListener listener) {
mListener = listener;
}
public static void unbindListener() {
mListener = null;
}
}
SmsListener.java
public interface SmsListener {
interface OTPListener{
void messageReceived(String messageText,String messageSender);
}
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.aaa.aaa">
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.BROADCAST_SMS"
tools:ignore="ProtectedPermissions" />
<application
android:allowBackup="true"
android:icon="#drawable/b"
android:label="#string/app_name"
android:roundIcon="#drawable/b"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:priority="2147483647"
android:name=".MyReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS"
>
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
This is my application code. I want to toast the message and sender when a new message is arrived (even app is killed or destroyed), but in samsung j5 mobile, nothing happened.
You are probably running into a permission issue. The Samsung J5 is an older Samsung model, so I assume your other "mobiles" are also older phones running older android releases. Which leads me to think that you maybe running into a permission issue with the J5 as it would probably be running a newer android release. Here is how you can get permission to read SMS on newer android releases!
I am following this tutorial to make a step counter and it works well as an android project but when I make the android project a library and want to use it in unity3d, it is crashing and giving me an error class not found: exception
My unity code is as follows:
void Start ()
{
#if UNITY_ANDROID
AndroidJNI.AttachCurrentThread();
androidClass = new AndroidJavaClass("com.test.testapp.MainActivity");
#endif
}
#if UNITY_ANDROID
public void checkMyIntOnJava(string message){
if (message == "READY") {
int myInt = androidClass.CallStatic<int>("getMyInt");
guiText.text = "My Int: " + myInt;
}
}
and my android code is as follows:
public class MainActivity extends UnityPlayerActivity
implements OnDataPointListener, GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener
{
public static void callbackToUnityMethod(int num, String gameObject,String methodName){
_myInt = num;
Log.e("GoogleFit", "in callbackToUnityMethod");
UnityPlayer.UnitySendMessage(gameObject, methodName, "READY");
}
}
After making an android jar, I keep it in the plugin folder in unity3d.
Did I miss anything?
My Android Manifest file is as following:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.testapp" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" />
<application android:label="#string/app_name">
<activity android:name="com.xxx.testapp.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="com.xxx.testapp.UnityPlayerActivity"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:label="#string/app_name" android:launchMode="singleTask" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</application>
</manifest>
Here's the two things I would try.
First change the following line in you AndroidManifest.xml so that the package scoping matches on the android:name property.
<activity android:name="com.xxx.testapp.MainActivity"
android:label="#string/app_name">
to
<activity android:name="com.test.testapp.MainActivity"
android:label="#string/app_name">
The other potential problem is that your class isn't being compiled because it is missing concrete implementations of the abstract methods in the parents classes and interfaces. To fix that add these implementations to MainActivity
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public void onConnected(Bundle bundle) {
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
#Override
public void onDataPoint(DataPoint dataPoint) {
}
This is my source code, it show no error in the Ide but, it stop on the device.
I use speech to say something to the program, and the program depending of the record, show me differents answers.
I Dont know what more do. The problem apparently starts from the methodod setText.
Thank U
protected static final int RESULT_SPEACH =1;
private Button record, speak;
TextToSpeech t1;
String SpokedText;
private EditText txtView;
private EditText txtView2;
TextToSpeech t1;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mai);
record = (Button) findViewById(R.id.record);
speak = (Button) findViewById(R.id.speak);
speak.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
record();
}
});
}
public void record() {
Intent reconize = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
reconize.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
reconize.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
reconize.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.Say_something));
try {
startActivityForResult(reconize, RESULT_SPEACH);
} catch (ActivityNotFoundException a) {
Toast t = Toast.makeText(getApplicationContext(), "Tu dispositivo no puede ejecutar este tipo de operaciones", Toast.LENGTH_LONG);
t.show();
}
}
#Override
public void onActivityResult (int requestCode, int resultCode, Intent Data) {
super.onActivityResult(requestCode,resultCode,Data);
switch (requestCode) {
case RESULT_SPEACH: {
if (resultCode == RESULT_OK && null != Data) {
SpokedText = data.getStringExtra(RecognizerIntent.EXTRA_RESULTS);
txtView2.setText(SpokedText);
setText(SpokedText);
}break;
}
}
}
public void setText(String string){
if (txtView2.equals("Good Morning")){
txtView.setText("Good Morning Sir");
}else if(txtView2.equals("I need your help")){
txtView.setText("Ok, ¿How can i help you?");
}
}
#Override
public void onInit(int status) {
if (status== TextToSpeech.SUCCESS){
int result = t1.setLanguage(Locale.getDefault());
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED){
Log.e("TTS", "This Lenguaje is not supported");
}else{
speakOut();
}
}
}
#TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void speakOut(){
String text = txtView.getText().toString();
t1.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
}
Could the problem may be in the AndroidManifest Xml?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dower.myapplication">
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<application
android:allowBackup="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".PantallaDeInicio"
android:label="#string/StarScreen"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.PICK_ACTIVITY"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Casanova"
android:label="#string/casaNova"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.PICK_ACTIVITY"></action>
<category android:name="android.intent.category.APP_BROWSER"></category>
<action android:name="android.intent.action.VOICE_COMMAND"></action>
<category android:name="android.intent.category.VOICE"></category>
</intent-filter>
</activity>
<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
The problem is that you can't equate a control with a string.
if (txtView2.equals("Good Morning")){
Should be
if (txtView2.getText().toString().equals("Good Morning")){
And you need to do the same each time you want to check the string in TextView controls
App Crash on button click. Here is the log.
Dealing specifically with trying to store a user into Parse.com as my backend. I have a java class called RegisterActivity with corresponding xml file, leading me to think it could be a null pointer exception, but I tested, and that doesnt seem to be the problem. Here are the 3 classes in which I believe are involved with the problem.
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
public class RegisterActivity extends Activity {
protected EditText mUsername;
protected EditText mUserEmail;
protected EditText mUserPassword;
protected Button mRegisterButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
//initialize
mUsername = (EditText)findViewById(R.id.usernameRegisterEditText);
mUserEmail= (EditText)findViewById(R.id.emailRegisterEditText);
mUserPassword= (EditText)findViewById(R.id.passwordRegisterEditText);
mRegisterButton = (Button)findViewById(registerButton);
//listen to register button click
mRegisterButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//get the username,password, and email, then convert to string
String username = mUsername.getText().toString().trim();
String email = mUserEmail.getText().toString().trim();
String password = mUserPassword.getText().toString().trim();
//store user and parse
ParseUser user = new ParseUser();
user.setUsername(username);
user.setPassword(email);
user.setEmail(password);
user.signUpInBackground(new SignUpCallback() {
#Override
public void done(ParseException e) {
if(e == null){
//user signed up successfully
Toast.makeText(RegisterActivity.this, "Welcome!", Toast.LENGTH_LONG).show();
//take user to homepage
}else{
//error signing up user
}
}
});
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_register, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Here is the corresponding activity_register.xml
<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" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.parse.inclassmode.RegisterActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:hint="username"
android:ems="10"
android:id="#+id/usernameRegisterEditText"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="142dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="email"
android:ems="10"
android:id="#+id/emailRegisterEditText"
android:layout_below="#+id/usernameRegisterEditText"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="password"
android:ems="10"
android:id="#+id/passwordRegisterEditText"
android:layout_below="#+id/emailRegisterEditText"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="sign up"
android:id="#+id/registerButton"
android:layout_marginTop="42dp"
android:layout_below="#+id/passwordRegisterEditText"
android:layout_alignParentStart="true" />
</RelativeLayout>
MainActivity.java class which includes my keys for Parse.com
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.parse.Parse;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Enable Local Datastore, ID's hidden
Parse.initialize(this, "id", "id");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
and finally my android manifest, which launches the register activity then takes the user to the home screen.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.parse.inclassmode" >
<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/AppTheme" >
<activity
android:name=".RegisterActivity"
android:label="#string/title_activity_register" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="InClassMode" >
</activity>
</application>
</manifest>
Figured it out!
For those of you who may come across this problem, create a new class that is not an activity, from there, initialize the Parse.