- Forum-Beiträge: 14
14.04.2016, 11:07:39 via Website
14.04.2016 11:07:39 via Website
Servus ihr lieben,
Ich versuche derzeit in meine App WhatsApp zu integrieren.
Allerdings klappt das ganze nicht so
hier mal die WhatsApp.java
public class WhatsApp extends Fragment {
private EditText message;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle args) {
View android = inflater.inflate(R.layout.fragment_radios5, container, false);
message = (EditText) android.findViewById(R.id.editText1);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, (R.id.editText1));
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
return android;
}
}
und hier die xml
fragment_radios5
...
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.hitarena.app.MainActivity$PlaceholderFragment$WhatsApp"
tools:ignore="HardcodedText">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="831"
android:background="@drawable/wallpaper">
<TableLayout
android:id="@+id/radioListUi"
android:layout_width="fill_parent"
android:layout_height="0px">
</TableLayout>
</ScrollView>
</LinearLayout>
<EditText
android:id="@+id/editText1"
android:hint="
Du möchtest eine Störung melden ?
Du hast Wünsche oder Grüße?
Deine Nachricht hier..."
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_height="200dp"
android:layout_marginTop="50dp"
android:layout_width="fill_parent"
android:layout_gravity="center_horizontal" />
<Button
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:onClick="sendMessage"
android:layout_marginTop="300dp"
android:text="Senden über WhatsApp"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal" />
Ref:
code2care.org/pages/how-to-sends-whatsapp-message-your-android-app-using-intent/
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.