Android studio comment posting page not working

本秂侑毒 提交于 2021-01-29 06:04:19

问题


I want to make a comment page like Instagram in the project I have done on Android studio. The comment fragment is coming, but when I write the comment and send it, it stops.Comments section does not occur in the firebase.I want to post comments on my project and then see those comments.The run part expresses like this. I have searched but could not find

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.geziproject">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <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.Geziproject">
        <activity android:name=".AnasayfaActivity"
            android:theme="@style/Theme.Geziproject.NoActionBar">
        </activity>
        <activity android:name=".MainActivity2" />
        <activity android:name=".LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main">
        </activity>
        <activity android:name=".bos" />
        <activity android:name=".kayitol" />
        <activity android:name=".kullanicigiris" />
    </application>

</manifest>

Logcat:

Run:

Exception thrown while unbinding
    java.lang.IllegalArgumentException: Service not registered: lu@1581393
        at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1870)
        at android.app.ContextImpl.unbindService(ContextImpl.java:1847)
        at android.content.ContextWrapper.unbindService(ContextWrapper.java:755)
        at ci.f(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):1)
        at ci.d(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):2)
        at lv.E(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):9)
        at lf.a(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):3)
        at ef.run(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):3)

fragment_yorumyaz.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Yorumyaz1Fragment">
    <androidx.appcompat.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/toolbar_yorumlar">

    </androidx.appcompat.widget.Toolbar>
    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar_yorumlar"
        android:id="@+id/recycler_yorumlar"
        android:layout_above="@+id/bottom_relative">

    </androidx.recyclerview.widget.RecyclerView>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/bottom_relative"
        android:background="#fff"
        android:padding="4dp"
        android:layout_alignParentBottom="true">
        <com.mikhaellopez.circularimageview.CircularImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:id="@+id/profilresmi_yorumlar"
            android:src="@mipmap/ic_launcher">
        </com.mikhaellopez.circularimageview.CircularImageView>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Yorumunuzu giriniz"
            android:layout_centerVertical="true"
            android:id="@+id/edit_yorumlar"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="10dp"
            android:layout_toLeftOf="@+id/gonder"
            android:background="@android:color/transparent"
            android:layout_toRightOf="@+id/profilresmi_yorumlar"
            >
        </EditText>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:text="Gönder"
            android:id="@+id/gonder"
            android:layout_centerVertical="true"
            android:layout_marginEnd="5dp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="5dp"
            android:textStyle="bold"
            android:textColor="@color/design_default_color_primary"></TextView>

    </RelativeLayout>
    
    
</RelativeLayout>

Yorumyaz1Fragment.java:

public class Yorumyaz1Fragment extends Fragment {
    EditText edit_yorumlar;
    ImageView profilresmi_yorumlar;
    TextView gonder;
    String gonderi_id;
    String gonderen_id;
    FirebaseUser mevcutkullanici;
    private Intent intent;
    FirebaseDatabase firebaseDatabase;
    DatabaseReference reference;


    public void YorumlarFragment() {
        // Required empty public constructor
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootview = inflater.inflate(R.layout.fragment_yorumyaz, container, false);
        Toolbar toolbar = (Toolbar) rootview.findViewById(R.id.toolbar_yorumlar);
        ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
        ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Yorumlar");
        ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(v -> getActivity().finish());
        edit_yorumlar = (EditText) rootview.findViewById(R.id.edit_yorumlar);
        profilresmi_yorumlar = (ImageView) rootview.findViewById(R.id.profilresmi_yorumlar);
        gonder = (TextView) rootview.findViewById(R.id.gonder);
 mevcutkullanici= FirebaseAuth.getInstance().getCurrentUser();

        
        Intent intent= new Intent();
        gonderi_id=intent.getStringExtra("gonderi_id");
        gonderen_id=intent.getStringExtra("gonderen_id");

        gonder.setOnClickListener(v -> {
            if (edit_yorumlar.getText().toString().equals("")) {
                Toast.makeText(getActivity(), "Boş yorum gönderemezsiniz", Toast.LENGTH_LONG).show();

            } else {
                yorumEkle();
            }

        });


        return rootview;
    }

    private void yorumEkle() {
        DatabaseReference yorumlarYolu = FirebaseDatabase.getInstance().getReference("yorumlar").child(gonderi_id);
     

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("yorum", edit_yorumlar.getText().toString());
        hashMap.put("gonderen", mevcutkullanici.getUid());
        yorumlarYolu.push().setValue(hashMap);
        edit_yorumlar.setText("");
       
 }

来源:https://stackoverflow.com/questions/65528708/android-studio-comment-posting-page-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!