簡體   English   中英

如何使用業務信息打開FaceBook,GoogleMaps或Dialer?

[英]How to open FaceBook, GoogleMaps or Dialer with business information?

我希望我的應用程序能夠在單擊aboutus.xml中的聯系信息時打開facebook或電話撥號程序,我該怎么做? 我是否需要使信息按鈕可單擊? 我對此很迷茫

主要活動

package com.example.vitoriano_vaz.eastbayvapes;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

/*
This app is for a local Vape Shop
 it's purpose is to increase customer flow, and provide a menu for Android users

 the array is going to be called = da_menu
 */
public class MainActivity extends AppCompatActivity {
    private static Intent java;

    /*
    called when the user clicks the send Button
     */

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


        /*
        This is new so i can send the user to the aboutUs.xml
         once the button on the main menu ( activity_main.xml ) is clicked
         */
        Button button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, AboutActivity.class);
                startActivity(intent);
            }
        });


        populateListView();
    }


    private void populateListView() {
        // Create the list of items

        String[] juiceMenu= {
                "#1 BLUEBERRY BOMBSHELL \nBlueberry Dessert",
                "#2 RICHIE RICH\nStrawberry cream",
                "#3 CHIQUITA\nCreamy Banana with a bready after taste",
                "#4 AFTERNOON DELIGHT\nKiwi Strawberry Dessert",
                "#5 POPPIN OTTERS\nMelted OtterPop",
                "#6 VIVA LA SANGRIA\nFruit more Fruit and Wine",
                "#7 OKOLE MALUNA\nPineapple fruit blend",
                "#8 CARMEN MIRANDA\nVanilla custard with a crisp",
                "#9 POMALADE\nIt's Bombalade!",
                "#10 IZUAL\nWhirlwind of icy Fruits",
                "#11 BUTTER STOTCH\nProfessor Chaos will surely get grounded for this one!",
                "#12 BLUE BULLS\nGrab the bull by the horns",
                "#13 GRAPE APE\nA grapple a day will keep the doctor away",
                "#14 BRUCE JUICE\nPerfectly blended old fashioned",
                "#15 DOC HOLIDAY\nN.E.T. Tabacco flavor",
                "#16 PEACHY KEEN\nPeach Cobbler",
                "#17 HULA\nStrawberry coconut ",
                "#18 NEW YORK\nPeppermint paddy dipped in chocolate",
                "#19 AL GORE\nFruit Loops plain and simple",
                "#20 LUX CHARMS\nThey're magically delicious",
                "#21 SAILOR JACK\nCracker Jack",
                "#22 GET HIM TO THE GREEK\nGreek Yogurt with peach",
                "#23 KEY WE LIE CHI\nFruit loving lychee",
                "#24 SPRING FLING\nA trois of honeydew berries ",
                "#25 GUMBY\nsour watermelon gummy",
                "#26 CHAI\nMILK - Milk Chai Tea",
                "#27 MR. BBEAN\nCappuccino cream",
                "#28 50 SHADES OF ORANGE\nDelightful orange cream",
                "#29 BLUE WAFFLES\nBlueberry Waffle",
                "#30 ENIGMA\n Mystery",
                "#31 MR. FREEZE\nPeppermint, Spearmint mainly just minty",
                "#32 CUP OF JOE\nCup of French Vanilla",
                "#33 BON JOVI\nVanilla Bourbon ",
        };
        // Build adapter
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                this,               // context for the activity
                R.layout.da_menu,   // Layout to create
                juiceMenu);         // Items to be displayed

        //configure list view
        ListView list = (ListView) findViewById(R.id.listViewMain);
        list.setAdapter(adapter);
    }
}

打開其他應用程序的信息

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myRelativeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#E3E5E1"
    android:inAnimation="@android:anim/slide_in_left">

    <TextView
        android:id="@+id/AboutUs"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:text="About Us"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/AboutUs"
        android:ems="10"
        android:inputType="textEmailAddress"
        android:text="eastbay@gmail.com"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/editText2"
        android:ems="10"
        android:inputType="textPostalAddress"
        android:text="1239 N Vasco RD Liver, Ca 94444"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/editText4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/editText3"
        android:ems="10"
        android:inputType="phone"
        android:text="(925)-961-9999"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/editText5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/editText4"
        android:text="facebook.com/eastbay"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/editText6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/editText5"
        android:text="Instagram: @eastbay"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/editText7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/editText6"
        android:ems="10"
        android:inputType="textMultiLine"
        android:text="Monday - Saturday 10:00 am - 8:00 pm\n Sunday 10:00 am - 6:00 pm" />
</RelativeLayout>

嘗試了解如何使用Intent,例如,如果您希望用戶使用特定的電話號碼打開Dialer,則可以執行以下操作,並使用所需的號碼進行更改

Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:0123456789"));
startActivity(intent); 

檢查此鏈接以了解意圖http://developer.android.com/training/sharing/send.html

否則在堆棧溢出中搜索特定的操作

對於facebook,

try {

context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/eastbay"));

} catch (Exception e) {

return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/eastbay"));

}

對於Instagram,

Uri uri = Uri.parse("http://instagram.com/_u/eastbay");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

likeIng.setPackage("com.instagram.android");

try {
    startActivity(likeIng);
} catch (ActivityNotFoundException e) {
    startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("http://instagram.com/eastbay")));
}

對於電子郵件,

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "eastbay@gmail.com" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));

對於撥號器,

Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:9259619999"));
startActivity(intent);

對於地圖,

String uri = "http://maps.google.co.in/maps?q=" + yourAddress;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);

在這里詢問之前,您應該使用Google。 編碼愉快!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM