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

Apps Starting a next activity issue.

ujjval rathod

Newbie
Jun 30, 2017
12
1
I have following .JAVA class for the activity and from this activity I want to start a next activity when a click on floating action button.
I am uploading the java nd xml code for the activity. Can anyone see any problem? Also, Do I need to add anything to the activity which starts from this activity?

Java:
package com.example.ujjval.dateandtimepicker;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.view.View;

/**
* Created by UJJVAL on 6/25/2017.
*/

public class secondactivity extends Activity{


    @Override
        // Method to link the JAVA class and Layout.
    protected void onCreate(Bundle savedInstanceState){

        super.onCreate(savedInstanceState);
        setContentView(R.layout.secondlayout );
    }
        // Method to call the main dateandtime activity
       // FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.floatingActionButton3);
         //  fab.setOnClickListener(new View.OnClickListener() {
       // @Override
         public void nextAct(View v){
        Intent i = new Intent(this, MainActivity.class);
        startActivity(i);
    }

}

Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/floatingActionButton3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_gravity="bottom|right"
        android:layout_marginBottom="26dp"
        android:layout_marginEnd="22dp"
        android:layout_marginRight="22dp"
        android:clickable="true"
        android:onClick="nextAct"
        app:fabSize="mini"
        app:srcCompat="@android:drawable/ic_input_add"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />


    <SearchView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:background="@color/colorPrimaryDark"
        android:layout_above="@+id/floatingActionButton3"
        android:layout_alignLeft="@+id/floatingActionButton3"
        android:layout_alignStart="@+id/floatingActionButton3"
        android:layout_marginBottom="18dp"
        android:id="@+id/searchView" />

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toEndOf="@+id/searchView"
        android:layout_toRightOf="@+id/searchView"
        android:layout_gravity="bottom|right"
        android:gravity="center"
        android:layout_alignLeft="@+id/searchView"
        android:layout_alignStart="@+id/searchView"
        android:id="@+id/textInputLayout3">

    </android.support.design.widget.TextInputLayout>

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/searchView"
        android:layout_alignLeft="@+id/searchView"
        android:layout_alignStart="@+id/searchView"
        android:layout_marginBottom="13dp"
        android:background="@android:drawable/button_onoff_indicator_on"
        app:srcCompat="@android:drawable/ic_menu_preferences" />
</RelativeLayout>
 
It would have been polite to update the thread and let the responders know that you successfully resolved it.

As to your current problem, can you provide more details please? Does the application crash? If so you should include a stack trace from the Logcat output.
 
Upvote 0
I have updated that thread..
Yes my application crashes. The actuaal problem is when I open second activity first, it crashesh. When I chage to first activity from the Menifest the app runs well. So I think there is a problem in linking this two activities.I will provide log in sometime.
 
Last edited:
Upvote 0
7/2/2017
12:45 PM Gradle sync started

12:45 PM Unregistered VCS root detected
The directory C:\Users\UJJVAL\AndroidStudioProjects\DateandTimePicker\application is under Git, but is not registered in the Settings.
Add root Configure Ignore

12:46 PM Gradle sync completed

12:46 PM Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

12:46 PM Gradle build finished in 12s 723ms

12:47 PM Executing tasks: [:app:assembleDebug]

12:47 PM Gradle build finished in 4s 967ms

12:52 PM Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

12:54 PM Gradle build finished in 1m 9s 193ms

12:54 PM Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources]

12:55 PM Gradle build finished in 1m 20s 863ms

12:56 PM Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources]

12:57 PM Gradle build finished in 22s 364ms

12:57 PM Executing tasks: [:app:assembleDebug]

12:58 PM Gradle build finished in 24s 991ms

1:16 PM Executing tasks: [:app:assembleDebug]

1:16 PM Gradle build finished in 26s 430ms

1:18 PM Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

1:19 PM Gradle build finished in 33s 594ms

1:19 PM Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources]

1:19 PM Gradle build finished in 25s 874ms

1:20 PM Executing tasks: [:app:assembleDebug]

1:20 PM Gradle build finished in 7s 420ms

2:39 PM Can't finish GitHub sharing process
Successfully created project 'DateandTimePicker' on GitHub, but initial push failed:
Unable to find remote helper for 'https'

2:43 PM Executing tasks: [:app:assembleDebug]

2:50 PM Gradle build finished in 6m 11s 139ms

2:50 PM Session 'app': Error Installing APKs

2:51 PM Executing tasks: [:app:assembleDebug]

2:52 PM Gradle build finished in 37s 105ms

2:53 PM Can't bind to local 8700 for debugger

2:53 PM Can't bind to local 8700 for debugger

3:31 PM Executing tasks: [:app:assembleDebug]

3:34 PM Gradle build finished in 2m 10s 381ms

3:34 PM ADB rejected shell command (dumpsys package com.example.ujjval.dateandtimepicker): closed

3:34 PM Executing tasks: [:app:assembleDebug]

3:36 PM Gradle build finished in 1m 30s 147ms

3:36 PM InvalidVirtualFileAccessException: Accessing invalid virtual file: file://C:/Users/UJJVAL/AndroidStudioProjects/DateandTimePicker/app/build/generated/source/r/debug/com/example/ujjval/dateandtimepicker/R.java; original:70264; found:-

8:27 PM Can't finish GitHub sharing process
Successfully created project 'ActivityMonitoring' on GitHub, but initial push failed:
Unable to find remote helper for 'https'

8:45 PM Platform and Plugin Updates: The following components are ready to update: Android Emulator, Google Repository, NDK, Android SDK Platform-Tools, Google Play Intel x86 Atom System Image, Google APIs Intel x86 Atom System Image

7/3/2017
6:15 AM Platform and Plugin Updates: The following components are ready to update: Android Emulator, Google Repository, NDK, Android SDK Platform-Tools, Google Play Intel x86 Atom System Image, Google APIs Intel x86 Atom System Image

9:07 AM Executing tasks: [:app:assembleDebug]

9:09 AM Gradle build finished with 2 error(s) in 2m 47s 285ms

10:44 AM Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

10:46 AM Gradle build finished in 1m 30s 492ms

10:46 AM Executing tasks: [:app:assembleDebug]

10:47 AM Gradle build finished in 33s 894ms

10:49 AM Can't bind to local 8746 for debugger
 
Upvote 0
2:43 PM Executing tasks: [:app:assembleDebug]

2:50 PM Gradle build finished in 6m 11s 139ms

2:50 PM Session 'app': Error Installing APKs

2:51 PM Executing tasks: [:app:assembleDebug]

2:52 PM Gradle build finished in 37s 105ms

2:53 PM Can't bind to local 8700 for debugger

2:53 PM Can't bind to local 8700 for debugger

3:31 PM Executing tasks: [:app:assembleDebug]

3:34 PM Gradle build finished in 2m 10s 381ms

3:34 PM ADB rejected shell command (dumpsys package com.example.ujjval.dateandtimepicker): closed

3:34 PM Executing tasks: [:app:assembleDebug]

3:36 PM Gradle build finished in 1m 30s 147ms

3:36 PM InvalidVirtualFileAccessException: Accessing invalid virtual file: file://C:/Users/UJJVAL/AndroidStudioProjects/DateandTimePicker/app/build/generated/source/r/debug/com/example/ujjval/dateandtimepicker/R.java; original:70264; found:-

8:27 PM Can't finish GitHub sharing process
Successfully created project 'ActivityMonitoring' on GitHub, but initial push failed:
Unable to find remote helper for 'https'

8:45 PM Platform and Plugin Updates: The following components are ready to update: Android Emulator, Google Repository, NDK, Android SDK Platform-Tools, Google Play Intel x86 Atom System Image, Google APIs Intel x86 Atom System Image

7/3/2017
6:15 AM Platform and Plugin Updates: The following components are ready to update: Android Emulator, Google Repository, NDK, Android SDK Platform-Tools, Google Play Intel x86 Atom System Image, Google APIs Intel x86 Atom System Image

9:07 AM Executing tasks: [:app:assembleDebug]

9:09 AM Gradle build finished with 2 error(s) in 2m 47s 285ms

10:44 AM Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

10:46 AM Gradle build finished in 1m 30s 492ms

10:46 AM Executing tasks: [:app:assembleDebug]

10:47 AM Gradle build finished in 33s 894ms

10:49 AM Can't bind to local 8746 for debugger
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones