• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android Java - Change View

Hello,

I made a simple app to change view to another view.

I trying to change android view to new layout but then i start it its crash on the botton i made in MainActivity, trying to run the code below.

And my MainActivity
Code:
package com.example.changeview;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    Button SecondActivityButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SecondActivityButton = findViewById(R.id.GotoSecondActivity);
        SecondActivityButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("myTag", "Change to SecondActivity");


                Intent switchActivityIntent = new Intent(MainActivity.this, SecondActivity.class);
                startActivity(switchActivityIntent);

            }
        });
    }


    public class SecondActivity extends AppCompatActivity {
        Button backButton;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_second);

            backButton = findViewById(R.id.activity_second_button);
            backButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Log.d("myTag", "Change to Main");
                }
            });
        }
    }
}

And my AndroidManufest.xml
Code:
<?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.example.changeview">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.ChangeView">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity$SecondActivity"
            tools:ignore="Instantiatable">
        </activity>
    </application>

</manifest>

Error Code:
Code:
--------- beginning of crash
2021-07-02 09:12:48.787 4667-4667/com.example.changeview E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.changeview, PID: 4667
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.changeview/com.example.changeview.MainActivity$SecondActivity}: java.lang.InstantiationException: java.lang.Class<com.example.changeview.MainActivity$SecondActivity> has no zero argument constructor
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3365)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.InstantiationException: java.lang.Class<com.example.changeview.MainActivity$SecondActivity> has no zero argument constructor
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
        at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1253)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3353)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
2021-07-02 09:12:48.880 4667-4667/com.example.changeview I/Process: Sending signal. PID: 4667 SIG: 9

Can someone help me out? Thanks for your time

Comparing Samsung A42 to Samsung S21

Was that the original FE? LOL. I had forgotten about that lesser - batteried? Note 7 model. Can't have been many around. From the embers of a disaster rose another flop that probably nobody could sell, or travel with as you say.

I'm very happy with my Poco F2 Pro which has very similar specs and screen to the S20 FE 5G, save for missing out on 120hz, OIS, IP68, wireless charging and longer updates.

I did receive a semi major upgrade yesterday (MIUI 12.5) with efficiency and performance, gesture and graphical improvements. I had been waiting for that.
Xiaomi make good stuff and I may get suckered into buying a third model soon with their weekly price drops :(



I found it interesting how Samsung kept going with their FE(Fan Edition) series phones, especially after the Note7 recall debacle. When they re-released the Note7 as Note7 FE, with a reduced battery capacity. Because the Note7 FE just gave me visions of arguing and explaining to airport security and airline staff, about what FE is.

Help unlink/remove duplicate contacts

how do I get rid of duplicate contacts? For instance when I go into my contacts some contacts have 2 or more entries in the list while some others have one entry but when I go to say send a text message the contacts number may show up more than once even though they are only listed in contacts once.
Go to.... Contacts > Menu (hamburger 3 lines) > Manage contacts... see screenshot

Sdo8Q2Pm.png


From here you can Merge, Delete, duplicate contacts.

(N.B. This information is based on the global, Exynos, model running stock Samsung, unbranded, firmware)

Another samsung.android.incallui question. But, with a twist??

I have looked into this a little bit and Ive heard its the Samsung system UI and I do believe it has nothing to do with incoming its what the person does on their dial pad. Texting , calling, and messaging. I will have more to post after a few tests and more research. I also believe it may be a third-party phone app they may be used instead of just using the regular phone app on the cell phone.

Help please

You can easily get your phone calls and even your texts for download on sprint no paper... I still go to the Sprint website I have not got the new T-Mobile sims cards I am going kicking and screaming I guess you could say.:oops: P.s I have also noticed hardly any of my texts are showing up on the text page so T-Mobile is not doing so well. I'm gonna haft to call them that's absurd. I at least want it accurate.

Help with Google app please!

Well re-reading through your initial posting, perhaps the Google app itself isn't so much the actual problem but it's just a secondary conflict to the text-to-speech function. (One is just a system-level, added app, the other an integrated part of the installed Android operating system on your device) Have you tried just going into your Settings menu and resetting the Speech-to-Text options?
https://speaking.email/FAQ/87/android-system-settings-for-speech-and-voice-recognition

SD won't take apps

I thought this problem was solved years ago. Now it's back, or never left. I was trying to move some to SD, but there's no such option. Please don't tell me I have to download ANOTHER app in order to do that (unless of course it's true).

Not a good idea to run apps from flash storage, and that's the way to think of sd cards, storage, not memory.

Unable to view location history

My kid did not delete the location data. I have mine enabled, and nothing is displayed either. You should not be able to enable location history and then no location history is displayed. Whatever apps are needed for it to work then, should be explained better by google, which has been doing a poor job with user interfaces for many years. Or maybe google is just interested in monetizing your location, which is why it is so obtuse.

Smartlife, cloudedge and aitwit notifications problem

I work for a company where we install video doorbells (not Ring). We have a few models that have a particular problem with a widely used app. By now I'm desperate to find a way to solve this, because it's really affecting our customers experience with the product. This is a problem they are only experiencing on Android devices. I'm hoping someone here has had this problem, or a similar one, and has some insight I haven't thought about before. On Apple the apps work without a glitch.

This problem is not related to a specific phone brand, but it only occurs on recent Android devices. So we see this problem on Samsung (A and S series), Huawei, OPPO, OnePlus, Xiaomi, etc. But only on devices that were released in the last year or so. Older devices do not seem to have this problem, as of yet (or those customers have not yet contacted us).

Expected behavior:
Our video doorbells use either the Aiwit, Smartlife or Cloudedge apps. When someone rings the doorbell, the customer should get a screen as if they are receiving a call. They can either accept that call or decline it. When they accept that call, the app should launch and they should have a video and audio connection, seeing the person who is standing in front of their door.

These are all the manufacturers in China? Suggest you contact them, and see if they can suggest anything. Maybe there's a common problem with them?

Does Android 4.1 run Google Play Store version 6.7.13?

Keep in mind that 6.7.13 version of the Play Store app is a very dated one. (Current version being 26.x.x) So you're likely to experience a lot of limitations when trying to interact with Google's current online Play Store service. Also, version 4.x.x of Android being very dated and no longer supported by Google, there isn't a lot of third-party developer support at this point neither. So finding apps that still work with Jelly Bean are still floating around in the Internet, but you'll probably find it easier to sideload APKs from sources like apkmirror.com than on the Play Store. With the caveat that apps that run just on your mobile device are one thing, apps that have to interact with online services will be more problematic.

Filter

Back
Top Bottom