so i have an application which has a default package as com.android.
within this package i have two packages as android.audio and android.video.
now i need to call activity1 from android.audio from activity2 in android.video.
i have tried using something like
Intent i = new Intent();
i.setClassName("android.video","android.audio.activity1");
startActivity(i);
but this doesnt seem to work.
what is the right way to do it? where have i gone wrong?
i m not able to navigate to any activity outside the package.
EDIT:
this is how it is declared in the manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_title" >
<activity
android:label="#string/app_title"
android:name=".WeaveActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="android.login.LoginActivity"></activity>
<activity android:name="android.login.RegisterActivity"></activity>
<activity android:name="android.video.activity2"></activity>
<activity android:name="android.audio.activity1"></activity>
</application>
Intent i = new Intent();
i.setClassName(activity2.this,activity1.class);
startActivity(i);
use above code and add these activity in your manifeast file.
AS you told your package name is com.android
<activity android:name=".audio.activity1"></activity>
<activity android:name=".video.activity2"></activity>
or use complete path as below
<activity android:name="com.android.audio.activity1"></activity>
<activity android:name="com.android.video.activity2"></activity>
and a small suggestion for you never use your package name as com.android because if use then while submitting the app to Google Play it wont accept it as the package com.android is used for android SDK.
in manifest decalre like
<activity android:name=”.activity1”
android:label=”Activity 1”>
<intent-filter>
<action android:name=”android.audio.activity1”/>
<category android:name=”android.intent.category.DEFAULT”/>
</intent-filter>
</activity>
and while calling from any activity...
startActivity(new Intent(“android.audio.activity1”));
hope this will help.
Check your package name.
I think you gave only "audi" instead of "audio"
I rewrote my entire package structure by giving project package name as com.android and rest of the sub packages as com.android.audio and com.android.video and now it seems to work. thanks for all your help.
Related
<-- I m getting this fatal error which occurred while trying to upload pictures for my app in the android studio.please help get rid of this error.whats the best solution? the error is: Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml -->>
----------
----------
: Unable to find explicit activity class {}; have you declared this
activity in your AndroidManifest.
<?XML version="1.0" encoding="utf-8"?>
<manifest XML ns:android="http://schemas.android.com/apk/res/android"
package="com.parse.starter" >
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="15"
android:maxSdkVersion="23"/>
<application
android:name=".StarterApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="#string/parse_app_id" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="#string/parse_client_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>
You have to check a package where MainActivity is placed. It should be com.parse.starter. It seems MainActivity is in other place and you are getting an exception.
This can happen when you say copy and paste an activity instead of adding it via Android Studio. Basically it just means you'll need to add this line to your AndroidManifest.xml:
<activity android:name=".your-activity-class-name"></activity>
I am trying to use the Uber usebutton but each time, it crashes giving the following error:
Unable to find explicit activity class {com.heyjude.heyjudeapp/com.usebutton.sdk.internal.GroupedInventoryCardActivity}; have you declared this activity in your AndroidManifest.xml?
I am unsure what to put in the AndroidManifest, currently as per the docs I have:
<meta-data
android:name="com.usebutton.applicationid"
android:value="app-myId" />
But it's clearly not working...
I have some more information, I checked the manifest-merger-debug-report.txt and found the following line
REJECTED from [com.usebutton:android-sdk:5.0.1] /Users/adamkatz/Projects/LavaLamp/Hey Jude/heyjudestudio/app/build/intermediates/exploded-aar/com.usebutton/android-sdk/5.0.1/AndroidManifest.xml:13:5-43:19
Why would the library manifest be rejected and how to make it accepted?
The maifest stuff maybe a red herring, your probably missing a library (The Uber library).
Here's a typical (working) AndroidMainfest.xml.
VERY important:
package="com.example.html2pdf"
replace with your package name (it's normally in your (local package) GroupedInventoryCardActivity.java file).
VERY important: Html2pdfActivity"
replace with one entry for activity for all your Activity files .GroupedInventoryCardActivity in your case (full path best package plus activity with dots (full stop's separating things, normally no slashes).
VERY VERY important:
com.heyjude.heyjudeapp/com.usebutton.sdk.internal.GroupedInventoryCardActivity is reffering to a library Activity (also with a package name the forward slash links the two packages). That's o.k.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.html2pdf"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.html2pdf.Html2pdfActivity"
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>
So package (replace/change):
package="com.heyjude.heyjudeapp"
and (replace/change/insert) Activity (name):
<activity
android:name="com.heyjude.heyjudeapp/com.usebutton.sdk.internal.GroupedInventoryCardActivity"
Hope this helps and not make it more confusing ;O)
All that goes into the AndroidManifest.xml file is this:
<application
<activity
<!-- your activities -->
</activity>
<!--Button SDK-->
<meta-data android:name="com.usebutton.applicationid" android:value="YOUR_BUTTON_APP_ID"/>
</application>
Did you remember to replace "YOUR_BUTTON_APP_ID" with your Button app ID found in the dashboard?
I am using Visual Studio 2015 and have a PCL based project created. All this application does is show a splash screen and then navigate to the next page. I am unable to get this to work on Android. Here is the link for the splash screen
The error I get:
The application could not be started. Ensure that the application has
been installed to the target device and has a launchable activity
(MainLauncher = true).
Additionally, check Build->Configuration Manager to ensure this
project is set to Deploy for this configuration.
I have followed this link and tried all the solutions there and still have the same result
Any tips to fix this?
Edit
Android Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Splash.Splash" android:installLocation="auto" android:versionCode="1" android:versionName="1.0">
<!--suppress UsesMinSdkAttributes-->
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:icon="#drawable/icon-3" android:name="mono.android.app.Application" android:allowBackup="true" android:label="Splash.Splash" android:debuggable="true">
<activity android:label="Splash screen" android:name="md5ac585b47313c1dc414c7b7a18f93e457.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:icon="#drawable/icon-3" android:noHistory="true" android:theme="#style/Theme.Splash" android:name="md5ac585b47313c1dc414c7b7a18f93e457.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="Splash.Splash.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.STM.STM" />
</intent-filter>
</receiver>
</application>
</manifest>
Edit
New Manifest below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Super.Super" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<application android:icon="#drawable/stmicon-3"></application>
</manifest>
EDITED: There was more than one problem in your question. I addressed two of them but the last one was the icon name.
Android resources can't have the '-' character in the name.
so this is the correction:
<application android:icon="#drawable/stmicon3"></application>
Initial answer:
Its wrong to have two activities with the same intent filter for launching.
So, first on your Manifest, remove entirely the two Activities tags.
For helping debugging this. please change your manifest to this (yes we are ignoring the Provider too)
So your final Manifest would be:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.yournamespace.courier">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="yournamespace">
</application>
</manifest>
After this, were gonna set the SplashActivity as MainLauncher:
[Activity(MainLauncher = true,
NoHistory = true)]
public class SplashActivity : AppCompatActivity
And finally the MainActivity:
[Activity(Icon = "#drawable/icon")]
public class MainActivity : FormsAppCompatActivity
You Can Do As Jon Sugguested Or Just Go Into Your Android Device Settings & Application Manager And uninstall the previous version of the application on your android device
I am running an app in Android Studio and it gives 2 app icons in Androi Studio.
Also, I have moved from Eclipse to Android Studio and now I'm having trouble with how to make the color of logcat same as in Eclipse.
My question is that there are 2 app icons when I run the app, and when I uninstall it, 2 of them have been removed. Is that normal in Android Studio?
I have found that Android Studio can copy keys from Eclipse.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mytrack.ph"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- Google Map v.2 permissions -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- GCM permissions -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<!-- Writing Persmission -->
<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
<uses-permission android:name="android.permission.WRITE_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACT"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity android:name="com.mytrack.ph.SplashActivity"
android:label="#string/app_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="#style/splashScreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.mytrack.ph.LoginActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_map_api_key"/>
<activity android:name="com.facebook.LoginActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/app_id"/>
<service android:name="com.my.track.service.MyTrackService"></service>
<receiver
android:name="com.my.track.service.MyTrackGcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.my.track.service" />
</intent-filter>
</receiver>
<service android:name="com.my.track.service.MyTrackGcmIntentService" />
<activity android:name="NavigationMenuActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:permission="com.google.android.c2dm.permission.SEND" >
></activity>
<receiver android:name="com.my.track.results.ConnectionChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
</application>
</manifest>
I though this is normal in android studio. Running an app gives 2 launcher icons.
PS:
my AndroidManifest.xml is inside main folder and I used eclipse to export to gradle build.
Im using Android Studio 0.8.6
thanks.
I got it! yes at last , i have to study gradles and stuff.
Actually I have 2 android projects inside the Project, one is a library and the other one is the main app.
I found out that when i imported those projects Android Studio (I exported the lib to gradle build from eclipse) doesn't care if that is a lib project or a main project. (Correct me if im wrong ).
so the only thing to make it work is to remove the intent-filter of that lib-android-project.
EDIT:
#all
solved it ! thanks to everyone, I never knew there was another AndroidManifest.xml , i thought eclipse removed it. and i thought Exporting it to gradle will remove it because it is checked as a library.
thanks for all your help.
The <intent-filter> that affects creating multiple launcher icon is the following one:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
Android Studio's manifest merger will always combine <intent-filter>s in library projects into main project's manifest. You may end up having multiple LAUNCHER intents in your synthesized manifest, thus having multiple launcher icons. To avoid this, simply remove the LAUNCHER intents from the library projects' manifest.
You declare two intent filter, used only one Intent filter in the activity, on AndroidManifest.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If you used two or more intent filter in AndroidManifest, then you will have two app icon, So remove it & set one intent filter.
I hove this is usedful to you.
i agree, since i made 2 activity(one for splash, one for main). In manifest i forgot to delete
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
so in the end when i install app, i will have 2 app.
There is most likely an imported Library project that has this intent filter.
1. Open your app manifest
2. At the bottom left click on "Merged Manifest"
3. Search and find which library project has the attribute
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
4. Remove it and ensure that now the filter is only on your App's <Application >class activity.
In my case, it was just because, in the manifest file, two activities were declared as launcher. Actually, I clicked on the launcher checkbox while making new activity, thinking it will transfer the launcher tag from the previous activity to this, but it created both activities as launchers.
When running android and doing debug, there is an another AndroidManifest.xml under src/debug. Make sure this manifest file matches the main one under src/main.
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<!You need to delete launcher intent filter from every other activity ->
</activity>
The "android.intent.category.LAUNCHER" intent filter decides which activity will launch when you tap on the application icon. If there are more than 1 entries, OS will create more than one app icon after installation. You need to make sure that there is a single entry of above intent filter in the Manifest file.
I have been able to create a *.apk file from my code, place the file
in IIS, and download it onto a number of Android phones. Upon the
install, the application works exactly as expected.
However, after a phone is rebooted, the application name is changed to
the fully-qualified Java class name of the activity in the menu (so
"MyActivity" becomes "com.mycompany.MyActivity"), and when I try to go
to Menu > Settings, I get an error that causes android to force close
my application.
Looking into DDMS, I see that I get an error indicating that it can
not find my Preferences activity, despite the fact upon initial
install, it works properly.
I'm using Eclipse on Windows XP, and have several Android devices at
my disposal to test with.
Any idea what's going on?
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/logo" android:label="#string/app_name"> <!--android:debuggable="true">-->
<activity android:name="com.company.app.ActivityMain"
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.company.app.Preferences"
android:label="#string/app_settings">
<intent-filter>
<category android:name="android.intent.category.PREFERENCE"></category>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
<service android:name="com.company.app.Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
So I finally got this to work. I think that the package installer on the HTC Hero (and maybe the HTC Droid Eris) has some issues.
I uninstalled my application from the phone, changed the name of my main activity, and re-deployed it onto the Hero. I started to immediately get a "Force Close." I connected the device to DDMS and looked at the error. It was still looking for my old activity name. I factory reset the device and reinstalled the same package (with the updated name) and everything works as expected.
So it seems that the package installer is caching some part of the old manifest or something, not really sure what exactly is going on there. I may play with it some more if I get time.
I don't know if someone else could verify this problem, maybe it's something that should be taken up with HTC?
try to use this manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/logo" android:label="#string/app_name"> <!--android:debuggable="true">-->
<activity android:name=".ActivityMain"
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=".Preferences"
android:label="#string/app_settings">
<intent-filter>
<category android:name="android.intent.category.PREFERENCE"></category>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
<service android:name=".Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>