• 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

Xfinity hell

My friend has been "accepted" for their wifi. The thing is he apparently has to download some crap app to get it and he supposedly doesn't have enough room on his phone. I tried apking it but it said "app not installed". I also read the reviews and most of them said it's useless. Is there some other way to set up the router?

Help Volume Decreases Gradually When Using USB-C Headphones or Speaker (Samsung Galaxy S21+)

Whenever I have either a set of headphones or a small speaker plugged into the USB-C port of my Samsung Galaxy S21+ the volume will very slowly and gradually lower itself until it's just about impossible to hear. If I close whatever audio app I'm listening to and reopen it the volume will usually return to it's original level only to once again start to decrease all on its own.

This doesn't happen when connected to Bluetooth, it's simply a problem when some sort of headphone or speaker is attached via USB-C. Also, this isn't the volume protection setting that prevents the earphones from accidentally blasting your eardrums. I've turned that feature off and it's still happening.

Note: Everything I use is via a 3.5mm headphone to USB-C adapter. Since I don't own any headphones or speakers that have their own USB-C connection I can't be sure if the problem is with the phone or the USB-C adapters (plural because it happens with every adapter I own, despite their being different brands and models.)

Thanks for any help anyone can offer!

Notifications not being consistently pushed

Good afternoon, everybody! I have a problem with just one app, Haiku. The notifications are not getting pushed at all. I tried many things first, then I spoke to the IT service in the institution where I work, they looked into it and after trying several changes in multiple settings , they told me it was my phone and not the app and recommended I check with Samsung. I have no problems with other notifications from other apps.

Ahhhhhoy

So let me expand more on my vacation,
Car Ride left Urbana around Six in the morning On a Saturday, after a few things that were slightly in the air.
I was mostly with my sister, and mother in the car for the first leg in the trip, we flew through Indiana, Ohio was a different matter, methinks we did stay the night in Springfield Ohio on the first day,
We, mostly they where my sis and mother were having to talk throughout on what was going on, life in general, I mostly just chilled out and wrote a few of my storylines down, kept myself silent mostly, but talked over like stopping somewhere for munchies or bathroom,
So after heading from Ohio to Pen, that took us a bit longer, I did photograph way too much, and next trip out of there, thinking of getting the 100GB cloud of google, that way I will be alright, instead of redownloading everything, I think I had around 700GB of photos alone, and I get so paranoid on what it jumped throughout different hoops and I did upload a few on here.

So after heading through just a wee little bit inwards of Pa, talked it over with my Aunt, who has lung cancer, that is devouring her - I remember lightly of my Father, that was established that matter, and she is going throughout Chemo right now, and seeing how her white blood cell count is riven upwards et all.
(Side note after talking with my wife about her, she clamped my right hand, and just gave me a massive hug, that was five weeks ago or was it six?)
So yeah we had a great time heading to Plymouth for the cottage, and eating some chowda out of the bread bowl, I did it once, and the spoon gave me a few cold sores, whom did not wash the dishes was not doing them so well.

first day at the cottage, with the three of us, we had to clean up the deck, did the windows, bed sheets, strip them off, got newer ones on. - Killed it within a few hours, general does it take us to a few days in between, so we swept and just did the first load into the first day, unpacked everything et all.

The second day we washed more of the cobwebs on the fan blades, also the windows, got out for a few times at the local beach snackbar, we ate there with our family together, and chilled without much pulling out punches either, so ontop of that, we walked on the beach.

So yeah I got caught up with my other Aunts who was there like a few times, we went to see everyone who we wanted to see too.

So yeah that is in a nutshell on what I was doing in the past.

Commands Headset

Hello, everybody.

I had a little water accident with my phone and I am currently struggling with my headphones:
The music is still played perfectly, however sometimes my phone recognises button presses as 'volume louder' or 'next song' from my headphone, eventough it doesn't have any buttons for that anyway.

I am struggling here to find a way to deactivate them, because a) I don't know how and b) I cant figure out the name of these commands. So far, I found only apps, which would deactivate the headset completely and not just these button-commands.
Can somebody point me in the right direction?

Best regards

Well, that was fun! (Not)

So I'm sitting here this morning, Joy Noelle sleeping on my leg while I'm using a laptop, and all of a sudden BOOM!!!! The house rattled. I grabbed Joy and pinned her to my chest, then walked around the house looking outside for a potential cause. Nothing.

I called my next-door neighbors and they immediately knew why I was calling; they had no clue either. I've heard sonic booms numerous times, and this definitely was not one, nor was it an earthquake.

We both got on NextDoor to see if we could find out what was happening. I was posting when... BOOOOMM!!!!! That was followed a few minutes later by another BOOOOOMMMMM!!!! The third was by far the worst.

I called 911. Guess what they told me? It was 'police training with another agency.' :eek:

On NextDoor, as I and others posted info about what we'd found out, the overall reaction was WTF?!! Why didn't anyone notify us in advance? Car alarms went off, pets got startled, people's nerves were rattled, and calls poured into area police departments--all of which could have been avoided by simply alerting us ahead of time!

We don't know the actual source of the booms, just that they caused a lot of unnecessary anxiety. I usually really love the Arcadia PD, but they goofed up this time, big time!

Quick Settings

I'm was looking for an explanation for the Quick Settings setup and individual button functions.

I found a Youtube video, about a year old, referring to the Galaxy s10. Among other things, it shows a "button grid" option, which my Galaxy s10e does not have. Is there somewhere else this can be adjusted?

Where can I find an explanation of the Quick Settings buttons functions?

Phone off during factory reset

Hello,

I'm new to this forum and I need your help.
Today I did a factory reset of my phone because lately, it kept going on and off and the samsung keyboard wasn't responding anymore. after selecting the factory reset option, all I could see was the phone alternating between "system update setting" and some "failure to update information" so I pressed the power button till it went off. Now I've been trying to turn it on to no avail. Please what can I do with it?
Your help will be very much appreciated.

alarms no longer showing up in alarm list.

Hello, the alarms work like normal, I get the dismiss/snooze screen when the alarm goes off, and all else is normal, but my alarms no longer show in the list where previous alarms are stored until I delete them.

I go to where the list is supposed to be by telling google to show alarms, and it takes me to where the list should be, so the area they are stored is there, just no alarms listed. All that is there is something stating my alarms will be listed there and a "No alarms"

I have already cleared the clock apps cash, and this is on a galaxy tab S2, android 7. Thanks

Help... OnePlus 6t Not allowing updates or reinstall of TWRP OR NEW OS.

Hey, everyone, I'm hoping someone can help me with this issue. So, I was avoiding any updates because I didn't want to lose root. Well, I eventually did update Lineage and lost root. Now for some reason I can't regain it. I have a OnePlus 6T (T-Mobile, bottloader unlocked, obviously
upload_2021-6-30_10-51-5.gif
), Linkage 17, and Magisk. Originally I flashed TWRP as a temp recovery, installed Magisk and Lineage (and Root Checker), and everything was fine - until the update. Now when I try to sideload with ADB nothing happens. I just receive a CMD error "ADB: requires an argument..." Long story short. I'd like to know how I can just completely start over, from scratch, flash different OS and keep root. Any help would be appreciated. Thanks in advance.

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.

What actually happens:
When the app is running on screen, we get the behavior as explained above.
When the app is running in the background or the screen is locked, the customer receives the notification tone, but no notification on screen. There is, however, a notification in the notification bar (the swipe down bar at the top of the screen, where all old notifications are shown). So no active notification on screen.

When does this problem present itself:
This problem presents itself whenever the apps aren't active on screen. So when:
  • The app is running in the background
  • The app is closed
  • The screen is locked and the app is running in the background
  • The screen is locked and the app is closed
How we have tried to solve the problem:
Below is a list of everything we have tried. None of these steps solved the problem.

Because this problem exists on a wide range of brands, the steps below were not possible on all brands (seeing how the settings menu's can varry widely from device to device).
  • Remove and reinstall the app
  • Set Apps > the app > Notifications > Show notification on lockscreen
  • Set Apps > the app > Permissions > Allow phone
  • Set Lockscreen > Show notifications
  • Set Lockscreen > Notifications > Show notifications on lockscreen
  • Set Notifications > Show on lockscreen
  • Set Notifications > Lockscreen > Show notifications
  • Set Permissions > Show notifications on lockscreen
  • Set Permissions > Notifications > Show notifications on lockscreen
  • Set Permissions > Lockscreen > Show notifications
  • Set Sound > More soundsettings > Lockscreen > Show notifications
  • Set Sound > More soundsettings > Show notifications on lockscreen
  • Unset Optimize > Battery > App-startup management > Automatic management
  • Set Optimize > Battery > App-startup management > Start automatically
  • Set Optimize > Battery > App-startup management > Secondary startup
  • Set Optimize > Battery > App-startup management > Active in background
  • Unset Phone > Battery > Close apps at lockscreen
  • Unset Phone > Clean > Clean memory > the app
All these steps have not solved the problem.

Filter

Back
Top Bottom