কম্পিউটার

একটি অ্যান্ড্রয়েড অ্যাপে গুগল অনুসন্ধান কার্যকারিতা কীভাবে যুক্ত করবেন?


এই উদাহরণটি দেখায় কিভাবে আমি একটি অ্যান্ড্রয়েডে গুগল সার্চ কার্যকারিতা যোগ করব।

ধাপ 1 − অ্যান্ড্রয়েড স্টুডিওতে একটি নতুন প্রকল্প তৈরি করুন, ফাইল ⇒ নতুন প্রকল্পে যান এবং একটি নতুন প্রকল্প তৈরি করতে সমস্ত প্রয়োজনীয় বিবরণ পূরণ করুন৷

ধাপ 2৷ − res/layout/activity_main.xml-এ নিম্নলিখিত কোড যোগ করুন।

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
   xmlns:tools="https://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:gravity="center"
   tools:context=".MainActivity">
   <EditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/editText"
      android:layout_centerInParent="true" />
   <Button
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/btnSearch"
      android:text="Search"/>
</LinearLayout>

ধাপ 3 − src/MainActivity.java

-এ নিম্নলিখিত কোড যোগ করুন
import androidx.appcompat.app.AppCompatActivity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
   EditText editText;
   Button btnSearch;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      editText = findViewById(R.id.editText);
      btnSearch = findViewById(R.id.btnSearch);
      btnSearch.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
            String term = editText.getText().toString();
            intent.putExtra(SearchManager.QUERY, term);
            startActivity(intent);
         }
      });
   }
}

পদক্ষেপ 4৷ − androidManifest.xml

-এ নিম্নলিখিত কোড যোগ করুন
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <uses-permission android:name="android.permission.INTERNET"/>
      <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/AppTheme">
         <activity android:name=".MainActivity">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>

আসুন আপনার অ্যাপ্লিকেশন চালানোর চেষ্টা করি৷ আমি ধরে নিচ্ছি আপনি আপনার কম্পিউটারের সাথে আপনার আসল অ্যান্ড্রয়েড মোবাইল ডিভাইসটি সংযুক্ত করেছেন৷ অ্যান্ড্রয়েড স্টুডিও থেকে অ্যাপটি চালাতে, আপনার প্রোজেক্টের অ্যাক্টিভিটি ফাইলগুলির একটি খুলুন এবং রানে ক্লিক করুন টুলবার থেকে একটি অ্যান্ড্রয়েড অ্যাপে গুগল অনুসন্ধান কার্যকারিতা কীভাবে যুক্ত করবেন? আইকন। একটি বিকল্প হিসাবে আপনার মোবাইল ডিভাইস নির্বাচন করুন এবং তারপরে আপনার মোবাইল ডিভাইসটি পরীক্ষা করুন যা আপনার ডিফল্ট স্ক্রীন প্রদর্শন করবে

একটি অ্যান্ড্রয়েড অ্যাপে গুগল অনুসন্ধান কার্যকারিতা কীভাবে যুক্ত করবেন?


  1. অ্যান্ড্রয়েড অ্যাপে ক্যালেন্ডার ইভেন্টগুলি কীভাবে যুক্ত করবেন?

  2. অ্যান্ড্রয়েড স্টুডিওতে লাইব্রেরি হিসাবে জার কীভাবে যুক্ত করবেন?

  3. Google অনুসন্ধানে কীভাবে আপনার লোকের কার্ড যুক্ত করবেন

  4. অ্যান্ড্রয়েডে কাজ করছে না এমন Google অ্যাপ কীভাবে ঠিক করবেন