I know that this question was asked and answered many times, but i cant find those answers useful to my program so i decided to ask another as my own. So i have two applications AppA and AppB, i want to open a certain activity of AppA from AppB here's my code for AppB :
public class AppB extends Activity {
static Context context;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
}
public void openNoti(View v) throws NameNotFoundException {
Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage("com.example.stealth.AppA");
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(getApplicationContext(), "error", 1000).show();
}
}
}
Im sure that i am invoking the right package name or address of AppA, but it just cant find it, saying that i might have not declared it on my Manifest.xml.
Here's Manifest for AppB :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.stealth"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.stealth.AppB"
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>
and here is the manifest of AppA :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.stealth"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.stealth.AppA"
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>
Please help me thank you. :)
ok the problem is with the package you are calling for
you have same name in two apps package com.example.stealth
and you are calling
"com.example.stealth.AppA" which is not there
Now rename AppA package to "com.example.stealth.AppA" it will work
Related
I am trying to send crash reports to email but when my app crashes nothing happens. I tried messing around with configurations but i just kept getting errors (unknown member mostly, wth that is). Here's my code for the class.
#ReportsCrashes(
mailTo = "me#gmail.com")
public class MyApplication extends Application
{
#Override
public void onCreate() {
super.onCreate();
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
My manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ghostdevelopment.ueni2"
android:versionCode="1"
android:versionName="1.0"
android:debuggable="true">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="25" />
<application
android:name="MyApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:label="#string/app_name"
android:name="com.ghostdevelopment.ueni2.MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="Ship Database"
android:name=".ShipInfo" />
</application>
</manifest>
According to your logcat it appears that your app has not included the ACRA library. You need to configure your build so that ACRA is included in your APK.
I am trying to write in file after android device boots. I have checked everything related to this topic here but none of them worked for me. My phone is Huawei Honor (H30-U10) and it's rooted. Android version 4.2.2. Here is my code:
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bog.ddrc.technicianmobile"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="bog.ddrc.technicianmobile.App"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="bog.ddrc.technicianmobile.activities.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:enabled="true"
android:name="bog.ddrc.technicianmobile.StartTMServiceAtBootReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
StartTMServiceAtBootReceiver.java:
public class StartTMServiceAtBootReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
String data = "text";
File path = Environment.getExternalStorageDirectory();
File file = new File(path, "test.txt");
try {
OutputStream os = new FileOutputStream(file);
os.write(data.getBytes());
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Remove
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
from your <receiver> block.
After trying all of mentioned answers and tricks, I finally find why the code is not work in my phone. Some Android phones like "Huawei Honor 3C Android 4.2.2" have a Statup Manager menu in their settings and your app must be checked in the list. :)
This is the error that shows on my logcat when i run my TagViewer.java for NFC on Eclipse. I am running a NFC program and basically it runs however at a certain period of time the program shuts down on its own.
08-29 14:06:33.677: E/ViewTag(22056): Unknown intent Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.android.nfc/.TagViewer }
This is from my Android Manifest. I am guessing that the error is from here because of the line on the error android.intent.action.MAIN and such.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.nfc"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-feature android:name="android.hardware.nfc" android:required="true"/>
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="16" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".TagViewer"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
this is from my java and basically the last line, when i put // the program will not shut down but it will show like a white page.However the title NFC is still showing so i know that it is slightly working
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTagContent = (LinearLayout) findViewById(R.id.tag_viewer);
mTitle = (TextView) findViewById(R.id.title);
resolveIntent(getIntent());
}
Change your Declaration activity "TagViewer" instead of ".TagViewer"
I'm working on an android project in which one of the activities includes a Maps view. I'm only after doing the code for displaying a simple Google Map but I bumped into this NoClassDefFoundError. I have checked some similar questions and tried the suggested solutions but still won't work. I have activated the Internet permision in the manifest file and the user library for the application. Does anyone have any suggestions on what might be the problem? Here's the activity code:
package com.mad.mylit;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class LocationsActivity extends MapActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
And here's my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mad.mylit"
android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".MyLitActivity"
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=".MapsActivity"></activity>
<activity android:name=".MyProfileActivity"></activity>
<activity android:name=".BusActivity"></activity>
<activity android:name=".EventsActivity"></activity>
<activity android:name=".LocationsActivity"></activity>
<activity android:name=".NotesActivity"></activity>
<activity android:name=".TimetableActivity"></activity>
<activity android:name=".MondayActivity"></activity>
<activity android:name=".TuesdayActivity"></activity>
<activity android:name=".WednesdayActivity"></activity>
<activity android:name=".ThursdayActivity"></activity>
<activity android:name=".FridayActivity"></activity>
<activity android:name=".CaherdavinActivity"></activity>
<activity android:name=".RaheenActivity"></activity>
<activity android:name=".UniversityActivity"></activity>
<activity android:name=".SplashScreen"
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>
All of the activities are in the same package.
Try to get new maps API key with your personal keystore.
Have you recently updated your ADT plugin?
Here and here are some talks about same prblem..
HY!
I always get the ActivityNotFound Error, but i already have my Activity declared in the Manifest.
Whats wrong?
Error:
10-17 20:28:24.881: ERROR/AndroidRuntime(2141): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.korn.supplierplan/com.korn.supplierplan.view.LVEntries}; have you declared this activity in your AndroidManifest.xml?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.supplierplan"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name = "android.permission.INTERNET"> </uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".view.Login"
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=".view.LVEntries"></activity>
</application>
</manifest>
Calling:
Intent i = new Intent (Login.this,LVEntries.class);
i.putExtra("JSON", array.toString());
startActivity(i);
The problem is in how you are naming the Activities in you Manifest file.
I'm guessing your class files are named Login.java not view.Login.java, am I right? If so change this:
<activity android:name=".view.Login" android:label="#string/app_name">
To This
<activity android:name="Login" android:label="#string/app_name">
Do the same for LVEntries
If they are named like view.Login.java then remove the prepended view. in the name.