Strangely map=frag.getMap(); does not throw nullpointerexception , but still the map is always null!
The same situation with or without running the handler.
I see the map (world map) but cannot do anything with the map object.
PRINT SCREE with project properties : http://i.stack.imgur.com/BGB65.jpg
Please have a look at the code and please advice where I am wrong.
package com.bestsiteeditor.bestwirelessdeals;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
public class Settings extends FragmentActivity{
LinearLayout submenu;
GoogleMap map;
LinearLayout mainLayout;
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
submenu =(LinearLayout) findViewById(R.id.submenu);
SubMenu sm = new SubMenu(this,submenu);
sm.getButtons();
mainLayout =(LinearLayout) findViewById(R.id.temp);
final Handler handler = new Handler();
handler.postDelayed(new Runnable(){
#Override
public void run() {
MapFragment frag = MapFragment.newInstance();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.add(mainLayout.getId(), frag);
fragmentTransaction.commit();
map=frag.getMap();
System.out.println("THEMAAP "+map);
if(map != null) {
System.out.println("THEMAAP NOT NULL "+map);
}else{handler.postDelayed(this, 500);}
}
}, 500);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
return ActionBar.HandleMenu(this, item.getItemId());
}
}
and the is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bestsiteeditor.bestwirelessdeals"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="19" />
<permission
android:name="com.suntrainer.suntrainer.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.suntrainer.suntrainer.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyAppActionBarTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDJuwvAd8Zzqasdasdadasdasd" />
<activity
android:name="com.bestsiteeditor.bestwirelessdeals.MainActivity"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.bestsiteeditor.bestwirelessdeals.Locations"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait" >
<intent-filter>
<action android:name="android.intent.action.LOCATIONS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.bestsiteeditor.bestwirelessdeals.Settings"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait" >
<intent-filter>
<action android:name="android.intent.action.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.bestsiteeditor.bestwirelessdeals.WatchList"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait" >
<intent-filter>
<action android:name="android.intent.action.WATCHLIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.bestsiteeditor.bestwirelessdeals.Profile"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait" >
<intent-filter>
<action android:name="android.intent.action.PROFILE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
You have
android:minSdkVersion="12"
So you need to change
public class Settings extends FragmentActivity{
to
public class Settings extends Activity{
Also it is better you check the availability of google play services before initializing
google map object.
From the docs
public final GoogleMap getMap ()
Gets the underlying GoogleMap that is tied to the view wrapped by this
fragment.
Returns the GoogleMap. Null if the view of the fragment is not yet
ready. This can happen if the fragment lifecyle have not gone through
onCreateView(LayoutInflater, ViewGroup, Bundle) yet. This can also
happen if Google Play services is not available. If Google Play
services becomes available afterwards and the fragment have gone
through onCreateView(LayoutInflater, ViewGroup, Bundle), calling this
method again will initialize and return the GoogleMap.
Edit:
Missing a meta tag in the applciation tag of manifest fie.
Pls make sure you followed all the steps #
https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Simply waiting 500 ms after the fragment transaction solved the issue.
Instead of Thread ,handler could be also implemented also.
fragmentTransaction.commit();
Thread thread= new Thread(){
#Override
public void run(){ try { synchronized(this){wait(500);}}catch(InterruptedException ex){ }
map=frag.getMap();
System.out.println("MAP OK"+frag.getMap());
}
};
thread.start();
Related
I have tried this on a few android phones with no luck (i did start the app once).
This was mostly generated from android studio 1.3.2 and from some questions like this and that and the other.
Perhaps someone can point out what i am doing wrong.
Thanks
edit: moved receiver inside app, but no joy.
edit2: added missing permissions for receiver. now seems to work on a nexus 4. but not on the kindle fire or the at&t tablets. although it seems to come right away if i press the circle icon on the azpen.
edit3: seems to work sometimes on the fires now.
package acme.startup;
import android.content.*;
public class BootReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent activityIntent = new Intent(context, MainActivity.class);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(activityIntent);
}
}
}
package acme.startup;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main,menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int id=item.getItemId();
if(id==R.id.action_settings)
return true;
return super.onOptionsItemSelected(item);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acme.startup" >
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver
android:name=".BootReceiver"
android:label="BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<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>
</application>
</manifest>
Every Component must be declared inside application tag into manifest. Here you declared receiver outside of application tag. Read Structure of the Manifest File.
Correct manifest wil be
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acme.startup" >
<application
android:allowBackup="true"
android:icon="#mipmap/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=".BootReceiver"
android:label="BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
You have to add permission to manifest file. Add this before your <application> tag :
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I want to do a simple exercise with permissions. I need to define and enforce a custom permission for my app called "DangerousApp" And after that I need to set up another app, "PermissionsLab" in such a way that it could use the "DangerousApp" but when I try to start the "DangerousApp" using "PermissionLab" I get an error: "Unfortunately, PermissionsLab has stopped"
AndroidManifest.xml of PermissionsLab:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="course.labs.permissionslab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<!-- TODO - add uses-permission elements -->
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="course.labs.permissions.DANGEROUS_ACTIVITY_PERM"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".ActivityLoaderActivity"
android:label="#string/title_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".BookmarksActivity"
android:label="#string/title_permissions" >
</activity>
<activity
android:name=".GoToDangerousActivity"
android:label="#string/title_activity_customization" >
</activity>
</application>
</manifest>
AndroidManifest.xml of DangerousApp:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="course.labs.permissionslab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<!-- TODO - add uses-permission elements -->
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="course.labs.permissions.DANGEROUS_ACTIVITY_PERM"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".ActivityLoaderActivity"
android:label="#string/title_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".BookmarksActivity"
android:label="#string/title_permissions" >
</activity>
<activity
android:name=".GoToDangerousActivity"
android:label="#string/title_activity_customization" >
</activity>
</application>
</manifest>
And the activity used to start DangerousApp:
package course.labs.permissionslab;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class GoToDangerousActivity extends Activity {
private static final String TAG = "Lab-Permissions";
private static final String DANGEROUS_ACTIVITY_ACTION = "course.labs.permissions.DANGEROUS_ACTIVITY";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.go_to_dangerous_activity);
Button startDangerousActivityButton = (Button) findViewById(R.id.start_dangerous_activity_button);
startDangerousActivityButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
startDangerousActivity();
}
});
}
private void startDangerousActivity() {
Log.i(TAG, "Entered startDangerousActivity()");
startActivity(new Intent(DANGEROUS_ACTIVITY_ACTION));
}
}
Thanks for your clarifications.
Permission help you to protect service, application, activity, ...
Here documentation:
http://developer.android.com/guide/topics/security/permissions.html#declaring
http://developer.android.com/guide/topics/security/permissions.html#manifest
for instance, if you want to protect an activity with a permission, in AndroidManifest declare a permission and put it on activity as this:
<manifest [...] >
<permission android:name="com.mycompany.MY_PERMISSION" android:protectionLevel="normal"
android:description="#string/permission_desc"
android:label="#string/permission_label" />
<application [...] >
<activity [...] android:permission="com.mycompany.MY_PERMISSION">
</activity>
</application>
</manifest>
In another application, if you want to call activity protected by permission, you have to add in AndroidManifest:
<uses-permission android:name="com.mycompany.MY_PERMISSION" />
I am facing a issue where my game becomes invisible in the menu after installation. Also when .apk installed, OPEN button becomes disabled and i'm unable to launch my game.
I made this game in Unity3D. I want to do deep-linking in my game so created my own Activity named as MainActivity extends UnityPlayerActivity and also did some changes in the AndroidManifest.xml file.
MainActivity.java
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;
public class MainActivity extends UnityPlayerActivity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.d("MainActivity", "onCreate called!");
}
#Override
public void startActivity(Intent intent)
{
boolean isStartActivity = true;
Uri uri = intent.getData();
if (uri != null && uri.getScheme().equals("abc"))
{
isStartActivity = false;
}
if (isStartActivity)
{
super.startActivity(intent);
}
else
{
Log.d("MainActivity", "MainActivity.startActivity() : uri = " + uri.toString());
UnityPlayer.UnitySendMessage("Main Menu", "JuliusReward", uri.toString());
}
}
}
AndroidManifest.xml
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.xyz">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
<!-- android:debuggable should be removed in release build -->
<application
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:debuggable="true">
<activity android:name="com.abc.xyz.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "myapp://com.example.myapp” -->
<data android:scheme="abc" android:host="com.example.abc"/>
</intent-filter>
</activity>
<activity android:name="org.onepf.openiab.UnityProxyActivity"
android:launchMode="singleTask"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<receiver android:name="com.amazon.device.iap.ResponseReceiver">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
</intent-filter>
</receiver>
</application>
<!--all-->
<uses-permission android:name="android.permission.INTERNET"/>
<!--Google Play-->
<uses-permission android:name="com.android.vending.BILLING" />
<!--For Tablets-->
<uses-feature android:name="android.hardware.telephony" android:required="false" />
</manifest>
Please check this post Intent filter for launcher and send activity
You should have an
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
and
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
I have an app that worked up to just recently.
The error in the Google play store is as follows:
java.lang.RuntimeException: Unable to instantiate application org.marsfirst.mars_app: java.lang.ClassNotFoundException: Didn't find class "org.marsfirst.mars_app" on path: DexPathList[[zip file "/data/app/org.marsfirst.mars_app-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.marsfirst.mars_app-2, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4703)
at android.app.ActivityThread.access$1600(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.marsfirst.mars_app" on path: DexPathList[[zip file "/data/app/org.marsfirst.mars_app-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.marsfirst.mars_app-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newApplication(Instrumentation.java:981)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
... 11 more
MainActivity:
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;//this gives me a warning that states its unused but it has been used in the past
import android.support.v4.app.Fragment;//this gives me a warning that states its unused but it has been used in the past
import android.app.Activity;//this gives me a warning that states its unused but it has been used in the past
import android.content.Intent;
import android.os.AsyncTask;
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.TextView;
import android.widget.Toast;
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.LogInCallback;
public class MainActivity extends ActionBarActivity {
private String un, pw;
public TextView username;
public EditText pass;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username = (TextView) findViewById(R.id.editloginusername);
pass = (EditText) findViewById(R.id.editpass);
Button login = (Button) findViewById(R.id.login);
login.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
un = username.getText().toString();
pw = pass.getText().toString();
ParseUser.logInInBackground(un, pw, new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (user != null) {
new CallMainPage().execute();
} else {
// username.setText("");
pass.setText("");
makeToast("User name or password not recognized.");
}
}
});
}
});
Button signup = (Button) findViewById(R.id.signup);
signup.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
new CallSignup().execute();
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public class CallSignup extends AsyncTask<Void, Void, String> {
protected String doInBackground(Void... urls) {
Intent intent = new Intent(MainActivity.this, Signup.class);
MainActivity.this.startActivity(intent);
return "";
}
}
public class CallMainPage extends AsyncTask<Void, Void, String> {
protected String doInBackground(Void... urls) {
Intent intent = new Intent(MainActivity.this, MainPage.class);
MainActivity.this.startActivity(intent);
return "";
}
}
public void makeToast(String text) {
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(getApplicationContext(), text, duration);
toast.show();
}
}
My manifest:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="org.marsfirst.mars_app"
android:protectionLevel="signature" />
<uses-permission android:name="org.marsfirst.mars_app" />
<application
android:name="org.marsfirst.mars_app"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="org.marsfirst.mars_app.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=".Signup"
android:label="#string/signup"
android:parentActivityName=".MainActivity" >
<intent-filter />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".MainPage"
android:label="Main Page" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".Webpage"
android:label="Website"
android:parentActivityName=".MainPage" >
<intent-filter />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainPage" />
</activity>
<activity
android:name=".TeamNews"
android:label="Team News"
android:parentActivityName="org.marsfirst.mars_app.MainPage" >
<intent-filter />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.marsfirst.mars_app.MainPage" />
</activity>
<activity
android:name=".OprPage"
android:label="OPR Page"
android:parentActivityName="org.marsfirst.mars_app.MainPage" >
<intent-filter />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.marsfirst.mars_app.MainPage" />
</activity>
<activity
android:name="org.marsfirst.mars_app.MechPage"
android:label="Mechanical Page"
android:parentActivityName="org.marsfirst.mars_app.MainPage" >
<intent-filter />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainPage" />
</activity>
<activity
android:name=".DriveNews"
android:label="Drive News"
android:parentActivityName=".MainPage" >
<intent-filter />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainPage" />
</activity>
<activity
android:name=".ProgramingPage"
android:label="Programming Page"
android:parentActivityName=".MainPage" >
<intent-filter />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainPage" />
</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>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="org.marsfirst.mars_app" />
</intent-filter>
</receiver>
</application>
</manifest>
File Explorer
http://imgur.com/UCwiJqP
I am unsure if it is a Code error or not, due to my research I believe it is a buildpath error however everything I have tried seems to fail please help
I will post any Additional screen shots or code that is needed. In attempt to fix the problem one "fix" I found was to change every thing to android:name=".DriveNews" instead of android:name=org.marsfirst.mars_app.DriveNews which was what it was originally
Thank you for any help you may be able to give.
Disclaimer: I am a noob in android development.
I think you would like to verify the following permission tags:
<permission
android:name="org.marsfirst.mars_app"
android:protectionLevel="signature" />
<uses-permission android:name="org.marsfirst.mars_app" />
The classloader is not able to find a class org.marsfirst.mars_app. From your code it seems like mars_app is a package. Same for android:name in application name.
Change
android:name="org.marsfirst.mars_app"
to
android:name="org.marsfirst.mars_app.YourApplicationClass"
where YourApplicationClass is the class that is extending Application class. If you don't have any such class just remove the name attribute.
According to official documentation of the application tag the name attribute should be
The fully qualified name of an Application subclass implemented for the application. When the application process is started, this class is instantiated before any of the application's components.
The subclass is optional; most applications won't need one. In the absence of a subclass, Android uses an instance of the base Application class.
can show you file explore?
e.g.
Right click the project -> Build Path -> Configure Build Path -> Order and Export and check the libraries that you use in your project.
Do you use proguard in your application?
if yes: check this from developer.google site. It may help you
The default proguard.cfg file tries to cover general cases, but you might encounter exceptions such as ClassNotFoundException, which happens when ProGuard strips away an entire class that your application calls.
You can fix errors when ProGuard strips away your code by adding a -keep line in the proguard.cfg file. For example:
-keep public class < MyClass >
For my Android App, I've declared multiple Activities in the AndroidManifest.xml file.
The AndroidManifest.xml file is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.btdt"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="#drawable/quizicon"
android:label="#string/app_name"
android:theme="#style/AppTheme" android:debuggable="true">
<activity android:name="QuizActivity"
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="QuizSplashActivity"> </activity>
<activity android:name="QuizGameActivity"> </activity>
<activity android:name="QuizHelpActivity"> </activity>
<activity android:name="QuizMenuActivity"> </activity>
<activity android:name="QuizScoresActivity"> </activity>
<activity android:name="QuizSettingsActivity"> </activity>
</application>
</manifest>
For some reason, my App never shows up on the Emulator.
I've read the answers of other people asking the same question, but my App still does not show.
I do not get any Compilation or Running Errors.
If it's any help, my QuizActivity.java file is
package com.example.btdt;
import android.os.Bundle;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.Menu;
import android.widget.TextView;
public class QuizActivity extends Activity {
TextView countDisplay;
public static final String GAME_PREFERENCES = "GamePrefs";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_splash);
SharedPreferences settings =
getSharedPreferences(GAME_PREFERENCES, MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settings.edit();
prefEditor.putString("UserName", "Ryan D'souza");
prefEditor.putInt("UserAge", 16);
prefEditor.commit();
countDisplay = new TextView(this);
this.setContentView(countDisplay);
if(settings.contains("UserName") == true)
{
String user = settings.getString("UserName", "Default");
countDisplay.setText(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.quiz_splash, menu);
return true;
}
}
Thank you for your help
Try To declare your other activities like that:
<activity
android:name=".YourClass"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.your.package.name" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
If the emulator does not show it, restart Eclipse and open it. Before to run the app, open the emulator and wait still it load.