Shinjan Chakraborty
Shinjan Chakraborty

Reputation: 1

Problem in going froma fragment to activity through intent in android although intent for map works

I have a fragment in which there are two buttons, one linking it to GoogleMap API which works perfectly fine whereas the other one linking to another activity crashes.

public class XBeeReceivedPacketsFragment extends AbstractXBeeDeviceFragment
{
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


        // Inflate the layout for this fragment.
        View view = inflater.inflate(R.layout.xbee_received_data, container, false);
        initializeUIElements(view);
        return view;
        }

private void initializeUIElements(View view) {
btn_Minedb=view.findViewById(R.id.btn_Minedb);
        btn_Minedb.setOnClickListener(new OnClickListener()
                                      {
                                          @Override
                                          public void onClick(View v) {

                                              Intent intent=new Intent(XBeeReceivedPacketsFragment.this.getActivity(), MineDatabase.class);
                                              startActivity(intent);
                                          }


                                      }
        );


        btn_Map=view.findViewById(R.id.btn_Map);
        btn_Map.setOnClickListener(new View.OnClickListener()
                                   {
                                       @Override
                                       public void onClick(View v) {

                                           Intent intent=new Intent(XBeeReceivedPacketsFragment.this.getActivity(), MapsActivity.class);
                                           startActivity(intent);
                                       }


                                   }
        );
}

and here is the code for the activity where the intent is directing,However the app carshes everytime I click this button

package com.digi.xbee.sample.android.xbeemanager.fragments;



import androidx.appcompat.app.AppCompatActivity;

import com.digi.xbee.sample.android.xbeemanager.R;


public class MineDatabase extends AppCompatActivity {



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

    }
}

Upvotes: 0

Views: 24

Answers (1)

Jujare Vinayak
Jujare Vinayak

Reputation: 123

Did you add MineDatabase activity in AndroidManifest.xml file? If not add it. Every component needs to be added in manifest file.

Upvotes: 1

Related Questions