2016-06-05 11 views
0

Es Fehler zeigt, dass kein geeignetes Verfahren in Start-Aktivität gefunden ist der Fehler:keine sutiable Methode für startActivity (Absicht) Methode gefunden

Error:(123, 17) error: no suitable method found for startActivities(Intent) method Context.startActivities(Intent[]) is not applicable (argument mismatch; Intent cannot be converted to Intent[]) method ContextWrapper.startActivities(Intent[]) is not applicable (argument mismatch; Intent cannot be converted to Intent[]) method Activity.startActivities(Intent[]) is not applicable (argument mismatch; Intent cannot be converted to Intent[]) package com.smartcodeone.newapp1;

public class MainActivity extends ListActivity{ 

    public static final String STRING_VAR = "com.smartcodeone.newapp1.HELLO_WORLD"; 
    public static final String STRING_RATE = "com.smartcodeone.newapp1.RAIING"; 
    /** 
    * ATTENTION: This was auto-generated to implement the App Indexing API. 
    * See https://g.co/AppIndexing/AndroidStudio for more information. 
    */ 
    private GoogleApiClient client; 

    public ListView listView_allContacts; 
    //ArrayAdapter adapter=new ArrayAdapter<String>(this,R.layout.,StringArray); 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     listView_allContacts=getListView(); 
       //(ListView) findViewId(R.id.listView_allContacts); 
     //listView_allContacts.setAdapter(adapter); 


     Button btnMsg = (Button) findViewById(R.id.btnMsg); 
     Button btnint = (Button) findViewById(R.id.btnshare); 
     // Button btnWidge t = (Button) findViewById(R.id.btnwidget); 
     // TextView etName1 = (TextView) findViewId(R.id.etName); 
     // EditText etName = (EditText) findViewId(R.id.tvName); 




     btnMsg.setOnClickListener(new View.OnClickListener() { 

      //when user click's this function will be called 
      public void onClick(View v) { 
       Intent intentvar = new Intent(getApplicationContext(), Main2Activity.class); 
       intentvar.putExtra(STRING_VAR, "Hello World"); //this is used to pass data to next intent 
       intentvar.putExtra(STRING_RATE, 3); 
       startActivity(intentvar); 
      } 
     }); 

     btnint.setOnClickListener(new View.OnClickListener() { 
      //when user want to share something 
      public void onClick(View v) { 
       Intent intentShare = new Intent(Intent.ACTION_SEND); 
       intentShare.setType("text/palin"); 
       intentShare.putExtra(Intent.EXTRA_TEXT, "This is invitation to all my friend to see this app"); 

       //ensure we have an appliction that can handle this type of data 
       if (intentShare.resolveActivity(getPackageManager()) != null) { 
        startActivity(intentShare); 
       } 
      } 
     }); 

     /*btnWidget.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View v) { 
       Intent intentwid = new Intent(getApplicationContext(), NewAppWidget.class); 
       startActivity(intentwid); 
      } 


     }); 
*/ 

     // ATTENTION: This was auto-generated to implement the App Indexing API. 
     // See https://g.co/AppIndexing/AndroidStudio for more information. 
     client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); 
    } 

    private int findViewId(int btnMsg) { 
     return 0; 

    } 


    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 


     getMenuInflater().inflate(R.menu.main_menu, menu); 
     return true; 


    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     // Handle action bar item clicks here. The action bar will 
     // automatically handle clicks on the Home/Up button, so long 
     // as you specify a parent activity in AndroidManifest.xml. 
     switch (item.getItemId()){ 
      case R.id.menu_new_contact: 

       // startActivities(new Intent(MainActivity.this, ContactDetailsActivity.class)); 

       break; 

     } 

     return super.onOptionsItemSelected(item); 
    } 

    /* @Override 
    public FragmentManager getSupportFragmentManager() { 
     return null; 
    } 
*/ 



    @Override 
    public void onStart() { 
     super.onStart(); 

     // ATTENTION: This was auto-generated to implement the App Indexing API. 
     // See https://g.co/AppIndexing/AndroidStudio for more information. 
     client.connect(); 
     Action viewAction = Action.newAction(
       Action.TYPE_VIEW, // TODO: choose an action type. 
       "Main Page", // TODO: Define a title for the content shown. 
       // TODO: If you have web page content that matches this app activity's content, 
       // make sure this auto-generated web page URL is correct. 
       // Otherwise, set the URL to null. 
       Uri.parse("http://host/path"), 
       // TODO: Make sure this auto-generated app URL is correct. 
       Uri.parse("android-app://com.smartcodeone.newapp1/http/host/path") 
     ); 
     AppIndex.AppIndexApi.start(client, viewAction); 
    } 

    @Override 
    public void onStop() { 
     super.onStop(); 

     // ATTENTION: This was auto-generated to implement the App Indexing API. 
     // See https://g.co/AppIndexing/AndroidStudio for more information. 
     Action viewAction = Action.newAction(
       Action.TYPE_VIEW, // TODO: choose an action type. 
       "Main Page", // TODO: Define a title for the content shown. 
       // TODO: If you have web page content that matches this app activity's content, 
       // make sure this auto-generated web page URL is correct. 
       // Otherwise, set the URL to null. 
       Uri.parse("http://host/path"), 
       // TODO: Make sure this auto-generated app URL is correct. 
       Uri.parse("android-app://com.smartcodeone.newapp1/http/host/path") 
     ); 
     AppIndex.AppIndexApi.end(client, viewAction); 
     client.disconnect(); 
    } 
    /* protected void onResume(){ 

     Dbhelper db =new Dbhelper(this); 
     ArrayList<String> names=new ArrayList<String>(); 
     for(int i=0;i<db.getAllContact().size();i++) 
      names.add(db.getAllContact().get(i).getName()); 
     ArrayAdapter adapter =new ArrayAdapter(this,android.R.layout.simple_list_item_1,names); 
     listView_allContacts.setAdapter(adapter); 

    }*/ 
} 

Antwort

1

ersetzen (in Ihrer onOptionsItemSelected-Methode):

startActivities(new Intent(MainActivity.this, ContactDetailsActivity.class)); 

mit:

startActivity(new Intent(MainActivity.this, ContactDetailsActivity.class)); 
+0

dank @ Evin1_ bekam die o Ausgabe, aber was wird die Aussage sein, wenn wir eine Reihe von Aktivitäten durchführen müssen? Wenn Sie wissen, lassen Sie es mich wissen – krunal

Verwandte Themen