سلام در این ساعت نوشتاری (یا مقاله ای) درباره اینکه کاربران برنامه (یا اپلیکیشن) اندروید شما (توسعه دهنده و برنامه نویس) از طریق شبکه اجتماعی گوگل پلاس به اشتراک بگذارند را قرار می دهم، امیدوارم مفید واقع گردد.

با پلتفرم اندروید گوگل پلاس، شما قادرید به افزودن دکمه +۱ در اپلیکیشن اندروید خود.

۱)شما ابتدا نیاز به مقدار دهی به آبجکت یا شیء PlusClient در اکتیویتی خود دارید.

۲) قرار دادنPlusOneButton در لای اوت خود:

    <com.google.android.gms.plus.PlusOneButton
        xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
        android:id="@+id/plus_one_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        plus:size="standard"
        plus:annotation="inline" />

۳) اختصاص دادن PlusOneButton به یک متغیر عضو در کنترل Activity.onCreate:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPlusClient = new PlusClient(this, this, this);
    mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
}

۴) بروزآوری وضعیت PlusOneButton متمرکز کردن اکتیویتی هر لحظه در کنترل Activity.onResume خود:

protected void onResume() {
    super.onResume();
    // Refresh the state of the +1 button each time the activity receives focus.
    mPlusOneButton.initialize(mPlusClient, URL);
}

برای دریافت اطلاعات بیشتر https://developers.google.com/+/mobile/android/#recommend_content_with_the_1_button را ببینید.

متن ترجمه شده

By Saeb Khanzadeh

Programmer and Computer Engineer