ActivityNotFoundException: but activity has been declared in manifest - java

hoping for some help. I am receiving an error:
04-13 15:01:45.336: E/AndroidRuntime(11065):
android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity};
have you declared this activity in your AndroidManifest.xml?
...
However I have declared said class RunActivity in the manifest. However, I notice that the path is not correct, it should be calling com.domakecreatedesign.runtracker.RunActivity, however as you can see from above, it is making a call for: com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity...
I have no idea why this is.
Here is my my manifest xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domakecreatedesign.getfit"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<permission
android:name="com.domakecreatedesign.getfit.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.domakecreatedesign.getfit.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<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.GET_ACCOUNTS"
android:maxSdkVersion="19" />
<uses-permission
android:name="android.permission.USE_CREDENTIALS"
android:maxSdkVersion="19" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="true" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/getfit_icon"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Splash screen -->
<activity
android:name="com.domakecreatedesign.getfit.SplashScreen"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main Activity -->
<activity
android:name="com.domakecreatedesign.getfit.MainActivity"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.getfit.ChooseLogin"
android:label="#string/title_activity_fblogin" />
<activity
android:name="com.domakecreatedesign.getfit.gplus_Login"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.getfit.Main_Menu"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunListActivity"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunMapActivity"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunActivity"
android:label="#string/app_name" />
<receiver
android:name=".TrackingLocationReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.domakecreatedesign.runtracker.ACTION_LOCATION" />
</intent-filter>
</receiver>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyATK_V5Ae2g7uJQM1EBhEcPZAL19B8jBuc" />
</application>
</manifest>
And the calling method is:
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
// the id argument will be the Run ID; CursorAdapter gives us this for free
Intent i = new Intent(getActivity(), com.domakecreatedesign.runtracker.RunActivity.class);
i.putExtra(com.domakecreatedesign.runtracker.RunActivity.EXTRA_RUN_ID, id);
startActivity(i);
}
Also worth noting, the application is contained within two packages
com.domakecreatedesign.getfit
com.domakecreatedesign.runtracker
Does this need to be declared somehow in the manifest?
Any help would be very much appreciated.
Many thanks

try ActivityName.this instead of getActivity()
Intent i = new Intent(getActivity(), com.domakecreatedesign.runtracker.RunActivity.class);
something like this,
Intent i = new Intent(AcitivityName.this, com.domakecreatedesign.runtracker.RunActivity.class);

Try this..
Intent i = new Intent();
i.setComponent(new ComponentName("com.domakecreatedesign.getfit", "com.domakecreatedesign.runtracker.RunActivity"));
startActivity(i);

Related

static shortcut android don't appear

I try to add a shortcut to my application, but when I do a long click I don't see it.
I double checked my application id, also the activity.
Here is what I try.
My shortcut.xml :
<shortcut
android:shortcutId="conso"
android:enabled="true"
android:icon="#drawable/ic_budgeting"
android:shortcutShortLabel="#string/shortcut_conso_short"
android:shortcutLongLabel="#string/shortcut_conso_long"
android:shortcutDisabledMessage="#string/shortcut_conso_dissable_message">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.****.stubs_dev.debug"
android:targetClass="com.******iviConsoActivity" />
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
</shortcut>
on manifest i add
on application and on activity i add also android:exported="true"
what's wrong with my code ?
EDIT here my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="****">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="....."
android:icon="#mipmap/..."
android:label="#string/app_name"
android:networkSecurityConfig="#xml/network_security_config"
android:resizeableActivity="false"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="icon">
....
<!-- Shortcuts-->
<meta-data android:name="android.app.shortcuts"
android:resource="#xml/shortcuts" />
</application>
My activity declaration :
<activity
android:name=".****onsoActivity"
android:screenOrientation="portrait"
android:exported="true"
android:theme="#style/AppTheme.NoActionBar"
>
<meta-data android:name="android.app.shortcuts"
android:resource="#xml/shortcuts" />
</activity>
Make sure your xml name is shortcuts.xml then make sure you are adding shortcuts.xml to the launcher Activity that has the android.intent.action.MAIN and android.intent.category.LAUNCHER intent filters.
Let's assume it is MainActivity then it would look like this
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="#xml/shortcuts" />

When I start a new activity, my app crashes. How to fix that?

private void userIsLoggedIn() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if(user != null){
Intent i = new Intent(getApplicationContext(), MainPageActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
}
}
That is the code that should change the activity ^^
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.tylerwilliams.openmessagingv2">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="Spectrum Messenger"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainPageActivity" />
<activity
android:name=".LoginActivitys"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FindUserActivity" />
</application>
</manifest>
That is my manifest code, I have tried to change it but whenever I do I either make more problems or it won't work. I am pretty sure its me just being a noob and that I have got something in the manifest wrong.

getting error while integrating map in android application

I want to integrate map in my android application. I have generated key through sh1 and using package name. but when I use map activity then it will give error. I have also installed google play service. but it cannot resolve on map callback activity.
It does not support even android:name in xml file
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney, Australia, and move the camera.
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
And My Manifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAz-m0JHQmk0qqairiEkkKFaiccgzTxb10"/>
<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>
Your Manifest file has should be like this.
Source click here!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="com.example.user.myapplication.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<permission
android:name="com.example.user.myapplication.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.
WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.
ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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/AppTheme" >
<activity
android:name="com.example.googlemaps.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDKymeBXNeiFWY5jRUejv6zItpmr2MVyQ0" />
</application>
</manifest>
There is a problem in your manifest file. <uses-permssion> tag comes out side of the <application> tag.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.myapplication" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAz-m0JHQmk0qqairiEkkKFaiccgzTxb10"/>
<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>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.myapplication" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your key"/>
<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>

Launch an application from another application, resumes always to root activity

I created a application to launch other with this code:
Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage("com.example");
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (i == null)
throw new PackageManager.NameNotFoundException();
startActivity(i);
} catch (PackageManager.NameNotFoundException e)
{
This code works correctly (can start application) for Facebook, Google Maps, another application created by me (com.example).
My test aplication (com.example) can resume, but always to root activity.
This application has two activities. First activity (Main Launcher), and a second activity. When I navigate to second activity (Main -> second), and execute application Launcher (above code), my application test run to foreground, but always show the first activity and destroy the second activity.
The test application (com.example) manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".Main"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Screen2"
android:label="#string/screen2Title"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout"
android:windowSoftInputMode="adjustResize">
</activity>
</application>
</manifest>
Facebook and Google Maps resume the last visible activity (not launcher activity).
Properties are well defined in above manifest?
The behavior of Facebook and Google Maps, is standard, or results of the code of activities, etc?
Thanks in advance for your help.
Problem solved, with the solution below.
Now I can start my application, if it is closed or resume (resume in any activity).
The code that starts the application is (Launcher):
Intent i;
PackageManager manager = getPackageManager();
try
{
i.addFlags(0);
i.setPackage(null);
if (i == null)
throw new PackageManager.NameNotFoundException();
startActivity(i);
}
catch (PackageManager.NameNotFoundException e)
{
}
My application that starts, has the following manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".Main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Screen2"
android:label="#string/screen2Title"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask" >
</activity>
<activity android:name=".Screen3"
android:label="#string/screen3Title"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask" >
</activity>
</application>
</manifest>
Now the application is resumed to any activity, without ever navigate to the root activity.

Google play services rev. 16 error

I am new to android. I want add a map to my application. I have the latest revision 16 of play services installed. When I run my application, I get an error a missing meta tag which i have added as below. I testing on android 2.3.6. See Manifets file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mylocation"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<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-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mylocation.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="A***************************IE" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>

Categories

Resources