Android - java.lang.NoClassDefFoundError: android.Maps.HomeScreen - java

I have just opened my code from a few weeks off and now it doesn't seem to work. I have a splash screen on open, which then moves to the home screen. The splash screen works, but when trying to move to the home page it falls over saying No Class Def Found. What does this mean and how can i fix it?
It says the problem is found with the below code which is in the splash screen class:
public void run()
{
//Finish the splash activity so it can't be returned to.
SplashScreen.this.finish();
// Create an Intent that will start the main activity.
Intent mainIntent = new Intent(SplashScreen.this, HomeScreen.class);
SplashScreen.this.startActivity(mainIntent);
}

please place HomeScreen in manifest file
<activity android:name=".HomeScreen"
android:label="#string/app_name">
</activity>

So what happened was I updated the Android SDK and apparently there have been a few problems with this, one being changing lib to libs. What I did was removed the activity and re-added. Thanks arcastro.
So if anyone has this problem from 16->17, check the activity's in the manifest file, and the lib folder

Related

Zxing in android always in landscape mode

I'm trying to implement a barcode reader.
https://www.youtube.com/watch?v=wfucGSKngq4&list=PLYBH5YZZegIf1DzLtuFmeDFqHYsfw1h1I&index=7&t=232s
I've followed this tutorial, and almost everything works fine. The only issue I have is that it always opens in landscape screen, and I have absolutely no clue what I do wrong.
butonScanare.setOnClickListener(v -> {
IntentIntegrator integrator = new IntentIntegrator(activity);
integrator.setCaptureActivity(CaptureActivity.class);
integrator.setOrientationLocked(false);
integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
integrator.setPrompt("Scanare");
integrator.initiateScan();
});
Any clue what I'm doing wrong?
Just add this in your AndroidManifest.xml file
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="android:screenOrientation"
android:stateNotNeeded="true"/>

How do I launch a specific (explicit) activity of another app

I want to launch a specific activity of another app from my app. For example, on the onCreate of my app, I want to launch the activity named Rolling (not main) activity of com.pas.webcam.pro. I have heard that you must have control of both apps to do this because you must add an intent filter to the manifest of the second app. This is not true though, because activity launcher apps in the Google Play Store can launch the Rolling Activity of IP Webcam Pro.
The Activity Launcher app is open source, so I tried reviewing the source code here. It was too complicated though, so I could not figure out how this app magically launches this activity. There are many other questions like this on Stack Overflow, and I have read every one. I have also tried lots of the code from the answers too, like this:
Intent intent = new Intent(); intent.setComponent(new ComponentName("com.pas.webcam", "com.pas.webcam.RollingActivity")); startActivity(intent);
I have also tried variants of this code from other posts. My app always crashes and I get variants (depending on the code I use) of the following error:
An error occurred
Invalid intent operation. Unable to find explicit activity class {com.pas.webcam.pro/com.pas.webcam.pro.Rolling}; have you declared this activity in your AndroidManifest.xml?
I have put both of the following in my Android Manifest and the same thing happens:
<uses-permission android:name="android.permission.GET_INSTALLED_PACKAGES" />
<activity android:name="com.pas.webcam.pro.RollingActivity"
Thanks in advance for any answers, I really appreciate it, as I have been working on this problem for a while.
Edit: Here is the activity of the app I want to launch: https://i.stack.imgur.com/Fa7Xq.jpg
Edit: David Wasser helped me solve the problem by giving me the code neccessary to solve the problem. It actually works! To anyone who wants to launch a specific activity of another app with code, please use this:
Intent intent = new Intent(); intent.setClassName("com.pas.webcam.pro", "com.pas.webcam.Rolling"); startActivity(intent);
You may replace com.pas.webcam.pro and Rolling with the app and activity of your choice, but this method truly works. Problem Solved!😀
Try this:
Intent intent = new Intent();
intent.setClassName("com.pas.webcam.pro", "com.pas.webcam.Rolling");
startActivity(intent);
Since you refer to the app as "IP webcam pro", I'm assuming the package name is "com.pas.webcam.pro" (found by Internet research).

How to add an already created activity to my project?

I'm creating an App, with some classmates, and we want to share our Activities with others, so we don't have to do all over again. Is that possible?
You can copy the activity class and the XML layout of the activity from one project to another.
The activity class file goes in the source folder and the xml layout goes in the layouts folder.
To declare the activity in the manifest.xml you have to add:
<activity
android:name="com.example.stockquote.StockInfoActivity"
android:label="#string/app_name" />
with the correct name and label (You have to declare in manifest, otherwise it won't work).
You can try to open other activities from main activity with:
Intent myIntent = new Intent(this, MyActivityName.class);
startActivity(myIntent);
In that case, you can add a Button to open the new activities and test if it works:
Button clickButton = (Button) findViewById(R.id.clickButton);
clickButton.setOnClickListener( new OnClickListener() {
#Override
public void onClick(View v) {
Intent myIntent = new Intent(this, MyActivityName.class);
startActivity(myIntent);
}
});
You can copy the activity class into the Java folder in your project and the XML layout of the activity from one project to another, paste it in the layout folder (under "res").
Remember to fix the package name, and define the activity in the manifest! <activity android:name=".the.right.path.ActivityName"/>
you should enter a path according to the package structure in your project
good luck

Android java trouble with start new activity

In MainActivity starts another activity via startActivityForResult
Intent intent = new Intent(MainActivity.this, AutorisationForm.class);
intent.putExtra("req", 1);
startActivityForResult(intent, 0);
Method onCreate executes successful, activity displays on the screen and then app crash. Eclipse returns "source not found" error.
How I can solve this problem?
P.S. All activities declared in manifest.
P.P.S All worked successfully before I add a lot of logic in MainActivity. This code and second class hasn't changed.
Problem solved. Mistake was in onDestroy() method in MainActivity. In this method app try to save unloaded file. Theme closed.
Undo all changes before adding "a lot of logic in MainActivity."
Add changes one at a time and test in between until you discover problem.
Problem discovered!

Prevent Re Loading an Activity while returning from Camera App

I am creating an app which uses the camera app to take pictures. Once I return from the camera app the entire view gets recreated. To stop this I have added
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
in the Manifest file for the specified activities. But this is still happening.
To be more precise of my issue, I am using Activity Group with TabHost. After a picture is taken using the camera I am redirecting the user to a different screen. But this is not working as the entire view is reloaded. Instead the user is taken back to the first screen in activity group.
I dont want this to happen. Is it posible to set orientation fro camera! How can I do this properly?
For those interested I am adding the code which I use to start camera
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri pictureUri = Uri.fromFile(new File("/sdcard/myimage.jpg"));
camera.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);
this.getParent().startActivityForResult(camera, PICTURE_RESULT);
Thanks

Categories

Resources