INTENT call not found

Asked

Viewed 260 times

1

The Delphi application calls a java application Activity and in the call displays the following error:

android.content.Activitynotfoundexception: Unable to find explicity Activity class {com.embarcadero.pedro.mostraparametrob/actMostraParametros}; have you declared this Activity in your Androidmaniftst.xml

but the Android Studio debug shows the two apps running.

follow the listings

  1. app:

    var   Intent     : JIntent;
    
          componente : JComponentName;
    
          apk,classe : JString;
    
    begin
    
          apk         := stringtoJstring('com.embarcadero.pedro.mostraparametrob');
    
          classe      := stringtoJstring('actMostraParametros');
    
          componente  := TJComponentName.JavaClass.init(apk,classe);
    
          Intent      := TJIntent.Create;
    
          Intent.setAction(apk);
    
          Intent.setComponent(componente);
    
          try
    
          SharedActivity.startActivity(Intent);
    
            except on E: Exception do
    
              ShowMessage(E.Message);
    
            end;
    
    end;
    
  2. the manifest.xml of the Activity provider app

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.embarcadero.pedro.mostraparametrob" >
    
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".actMain"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity
                android:name=".actMostraParametros"
                android:label="actMostraParametros" >
            </activity>
        </application>
    
    </manifest>
    
  3. to Activity called

    package com.embarcadero.pedro.mostraparametrob;
    
    import android.support.v7.app.ActionBarActivity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.widget.*;
    import android.view.*;
    
    public class actMostraParametros extends ActionBarActivity implements View.OnClickListener {
    
        private TextView edtValor1,  edtValor2;
        private Button  btnVoltar;
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.act_mostra_parametros);
    
            edtValor1 = (TextView)findViewById(R.id.edtValor1);
            edtValor2 = (TextView)findViewById(R.id.edtValor2);
            btnVoltar = (Button)findViewById(R.id.btnVoltar);
            btnVoltar.setOnClickListener(this);
    
            Bundle bdl = getIntent().getExtras();
    
            if (bdl.containsKey("para1"))
            {
                String valor1 = bdl.getString("para1");
                edtValor1.setText(valor1);
            }
            if (bdl.containsKey("para2"))
            {
                String valor2 = bdl.getString("para2");
                edtValor2.setText(valor2);
            }
    
        }
    
        public void onClick(View v)
        {
            finish();
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.menu_act_mostra_parametros, 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.
            int id = item.getItemId();
    
            //noinspection SimplifiableIfStatement
            if (id == R.id.action_settings) {
                return true;
            }
    
            return super.onOptionsItemSelected(item);
        }
    }
    
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.