Android studio intent ошибка

Using import android.content.Intent; from Lompa solve my problem on the main .java file and manifest but not in the second .java file

Here is the code:

package com.tutorial.helloworld;

import android.os.Bundle;
import android.util.Log;
import android.content.Intent;

public class SecondActivity extends Activity {

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

        String varString = getIntent().getStringExtra("Test");
        Log.d("HelloWorld - Second Activity", varString);
    }
}

Here the errors:

G:Crear_AppsProjectsHelloWorldappsrcmainjavacomtutorialhelloworldSecondActivity.java

Error:(6, 37) error: cannot find symbol class Activity

Error:(8, 5) error: method does not override or implement a method from a supertype

Error:(10, 9) error: cannot find symbol variable super

Error:(11, 9) error: cannot find symbol method setContentView(int)

Error:(13, 28) error: cannot find symbol method getIntent()

I was following the steps of a tutorial and gave me an error creating an «intent», I searched solutions but nothing works, idk if it’s because Android Studio is bugged or is my error, I restarted Android Studio too but nothing happen.

MyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    Log.d("HelloWorld","onCreate");

    Intent i = new Intent(this, SecondActivity.class);
    i.putExtra("Test","true");

    startActivity(i);
}

SecondActivity.java

public class SecondActivity extends Activity{

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

        String varString = getIntent().getStringExtra("Test");
        Log.d("HelloWorld - Second Activity",varString);
    }
}

AndroidManifest.xml

        </activity>
            <activity android:name="com.tutorial.helloworld.SecondActivity">
            </activity>
    </application>

Errors I get

G:Crear_AppsProjectsHelloWorldappsrcmainjavacomtutorialhelloworldMyActivity.java
Error:(20, 9) error: cannot find symbol class Intent
Error:(20, 24) error: cannot find symbol class Intent
G:Crear_AppsProjectsHelloWorldappsrcmainjavacomtutorialhelloworldSecondActivity.java
Error:(6, 37) error: cannot find symbol class Activity
Error:(8, 5) error: method does not override or implement a method from a supertype
Error:(10, 9) error: cannot find symbol variable super
Error:(11, 9) error: cannot find symbol method setContentView(int)
Error:(13, 28) error: cannot find symbol method getIntent()

В Activity есть список и внизу кнопка. По нажатию на кнопку должно открывать другое Activity, но приложение вылетает. Где ошибка? Весь код работает как надо, кроме этой кнопки. Я полный нуб :(

import android.app.Activity;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;



public class TodosOverview extends ListActivity implements View.OnClickListener {
    private TodoDbAdapter dbHelper;
    private static final int ACTIVITY_CREATE = 0;
    private static final int ACTIVITY_EDIT = 1;
    private static final int DELETE_ID = Menu.FIRST + 1;
    private Cursor cursor;

    Button button;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.todo_list);

        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(this);

        this.getListView().setDividerHeight(2);
        dbHelper = new TodoDbAdapter(this);
        dbHelper.open();
        fillData();
        registerForContextMenu(getListView());
    }
    @Override
    public void onClick(View v) {
        Intent intent = new Intent(this, MyActivity.class);
        startActivity(intent);
    }

    // Создаем меню, основанное на XML-файле
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.listmenu, menu);
        return true;
    }

    // Реакция на выбор меню
    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        switch (item.getItemId()) {
            case R.id.insert:
                createTodo();
                return true;
        }
        return super.onMenuItemSelected(featureId, item);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.insert:
                createTodo();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public boolean onContextItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case DELETE_ID:
                AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
                        .getMenuInfo();
                dbHelper.deleteTodo(info.id);
                fillData();
                return true;
        }
        return super.onContextItemSelected(item);
    }

    private void createTodo() {
        Intent i = new Intent(this, TodoDetails.class);
        startActivityForResult(i, ACTIVITY_CREATE);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        Intent i = new Intent(this, TodoDetails.class);
        i.putExtra(TodoDbAdapter.KEY_ROWID, id);
        // активити вернет результат если будет вызвано с помощью этого метода
        startActivityForResult(i, ACTIVITY_EDIT);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent intent) {
        super.onActivityResult(requestCode, resultCode, intent);
        fillData();

    }

    private void fillData() {
        cursor = dbHelper.fetchAllTodos();
        startManagingCursor(cursor);

        String[] from = new String[] { TodoDbAdapter.KEY_SUMMARY };
        int[] to = new int[] { R.id.label };

        // Теперь создадим адаптер массива и установим его для отображения наших данных
        SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
                R.layout.todo_row, cursor, from, to);
        setListAdapter(notes);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
                                    ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        menu.add(0, DELETE_ID, 0, R.string.menu_delete);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (dbHelper != null) {
            dbHelper.close();
        }
    }

}

geometria

1 / 1 / 0

Регистрация: 13.01.2013

Сообщений: 130

1

14.11.2013, 03:12. Показов 3290. Ответов 7

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

Intent берет значение по умолчанию, а не то, которое в классе Touch
подскажите почему?

Кликните здесь для просмотра всего текста

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package ru.lkja.fx;
 
import java.util.Timer;
import java.util.TimerTask;
 
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.os.Handler;
import android.service.wallpaper.WallpaperService;
import android.view.SurfaceHolder;
 
public class MainActivity extends WallpaperService {
 
    @Override
    public Engine onCreateEngine() {
        return new DemoWallpaperEngine();
    }
    private class DemoWallpaperEngine extends Engine {
        
        private static final int MAX_COUNT = 32;
        Bitmap picture;
        Timer timer;
        int count = 0;
        int cicl = 0;    
        
        public DemoWallpaperEngine(){
        picture= BitmapFactory.decodeResource(getResources(), R.drawable.p01);
        timer = new Timer(); 
        timer.schedule(new TimerTask() {
             
             @Override
             public void run() {
                 
                if(count == MAX_COUNT ){cicl = 0;}
                if(count == 0 ) {cicl = 1;}
                if(cicl == 0) { picture= BitmapFactory.decodeResource(getResources(), R.drawable.p01 + count); 
                 count--;}
            
                if(cicl == 1) {picture= BitmapFactory.decodeResource(getResources(), R.drawable.p01 + count); 
                     count++;}
             }
         }, 0,80);
         
         }     
        private boolean mVisible = false;
        private final Handler mHandler = new Handler();
        private final Runnable mUpdateDisplay = new Runnable() {
            public void run() { 
                draw();
            }
        };
 
        @Override
       public void onVisibilityChanged(boolean visible) {
          mVisible = visible;
            if (visible) {
                draw();
            } else {
               mHandler.removeCallbacks(mUpdateDisplay);
            }
        }
 
        @Override
        public void onSurfaceChanged(SurfaceHolder holder, int format,
                int width, int height) {
            draw();
        }
 
        @Override
        public void onSurfaceDestroyed(SurfaceHolder holder) {
            super.onSurfaceDestroyed(holder);
            mVisible = false;
            mHandler.removeCallbacks(mUpdateDisplay);
        }
 
        @Override
        public void onDestroy() {
            super.onDestroy();
            mVisible = false;
            mHandler.removeCallbacks(mUpdateDisplay);
        }
        
        public Intent getIntent() {
            Intent intent = new Intent();
            intent.putExtra("T", 10);
            return intent;
        }
                       
        private void draw() {
            SurfaceHolder holder = getSurfaceHolder();
            Canvas c = null;
            
            try {
                
                c = holder.lockCanvas(); 
                int w = c.getWidth();
                int h = c.getHeight();
               
                   if (c != null){ 
                    c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
                    Paint p = new Paint();
                    p.setAntiAlias(true);
                    
int u = getIntent().getIntExtra("T", 0);
Bitmap bmHalf = Bitmap.createScaledBitmap(picture, w, h, false);
c.drawBitmap(bmHalf, 0+u, 0, p);  
            
}
        } finally {
                if (c != null)
                    holder.unlockCanvasAndPost(c);
                     
               
            }
            mHandler.removeCallbacks(mUpdateDisplay);
            if (mVisible) {
                mHandler.postDelayed(mUpdateDisplay, 20);
   }
            
  }
 }
    
}

Кликните здесь для просмотра всего текста

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package ru.lkja.fx;
 
import android.app.Activity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
 
public class Touch extends Activity implements OnTouchListener {
    
    Integer T;
 
     
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        
        float t = 0;
        
        switch (event.getAction()){
        case MotionEvent.ACTION_DOWN:
            t = event.getX();
        case MotionEvent.ACTION_UP:
            if (t < event.getX()){
                T = 70;
            }
            else {T=40;}
        }
        
        return true;
    }
 
}



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

14.11.2013, 03:12

Ответы с готовыми решениями:

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
Выдает такую ошибку, хотя смартфон видит, он разрешает отладку, при запуске выдает такое сообщение,…

Почему здесь не работает скрипт, очень простой, ошибок на мой взгляд вроде нет
var login = prompt(‘Введите логин’,»);

If (login == ‘Черный властелин’) {

File::directory? здесь работает, здесь не работает
Доброго времени суток.

Учусь писать на Руби, дали задание написать поисковик. В документации…

Есть ли здесь ошибка? Писал скрипт в Unity для игры, но почему-то при запуске все зависает и нечего не работает
Я скинул пару примеров с циклами может ошибка в них.
1) int Amaunt = 0;
foreach (int…

7

name?

201 / 172 / 52

Регистрация: 01.06.2010

Сообщений: 371

14.11.2013, 03:21

2

в одном классе должно быть

Java
1
2
3
Intent intent = new Intent(this, Touch.class); 
    intent.putExtra("T", etFName.getText().toString());
    startActivity(intent);

в другом

Java
1
2
Intent intent = getIntent();
String fName = intent.getStringExtra("T");



0



geometria

1 / 1 / 0

Регистрация: 13.01.2013

Сообщений: 130

14.11.2013, 04:30

 [ТС]

3

первый класс привела к данному виду

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public class Touch extends Activity implements OnTouchListener {
    
    Integer T;
 
     
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        
        float t = 0;
        
        switch (event.getAction()){
        case MotionEvent.ACTION_DOWN:
            t = event.getX();
        case MotionEvent.ACTION_UP:
            if (t < event.getX()){
                T = 70;
            }
            else {T=40;}
        }
        Intent intent = new Intent(this, Touch.class); 
        intent.putExtra("T", 0);
        startActivity(intent);
        return true;
    }
 
}

второй к такому

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public Intent getIntent() {
        Intent intent = getIntent();
        getIntent().getIntExtra("T", 0);
        return intent;}             
        private void draw() {
            SurfaceHolder holder = getSurfaceHolder();
            Canvas c = null;
            
try {
                
               
                c = holder.lockCanvas(); 
                int w = c.getWidth();
                int h = c.getHeight();
               
                   if (c != null){ 
                    c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
                    Paint p = new Paint();
                    p.setAntiAlias(true);
                                        
int u = getIntent().getIntExtra("T", 0);
Bitmap bmHalf = Bitmap.createScaledBitmap(picture, w, h, false);
c.drawBitmap(bmHalf, u, 0, p);  }

и при этом выскакивает Force Stop…
где и что подправить?



0



name?

201 / 172 / 52

Регистрация: 01.06.2010

Сообщений: 371

14.11.2013, 09:57

4

заменить

Java
1
Intent intent = new Intent(this, Touch.class);

на

Java
1
Intent intent = new Intent(this, MainActivity.class);

Java
1
2
3
4
5
6
7
public int getT() {
        Intent intent = getIntent();
         return getIntent().getIntExtra("T", 0);
        }      
private void draw() {
...
int u = getT();



1



geometria

1 / 1 / 0

Регистрация: 13.01.2013

Сообщений: 130

15.11.2013, 01:49

 [ТС]

5

Java
1
2
3
4
public int getT() {
        Intent intent = getIntent();
         return getIntent().getIntExtra("T", 0);
        }

здесь почему то просит создать метод getIntent() и подчеркивает красным getIntent() в обоих случаях



0



name?

201 / 172 / 52

Регистрация: 01.06.2010

Сообщений: 371

15.11.2013, 01:59

6

а ну тогда вот так

Java
1
2
3
4
5
6
7
8
9
10
11
12
 
public class MainActivity extends WallpaperService {
private int t;
...   
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        t= intent.getIntExtra("T", 0);
        return START_STICKY;
    }
 
 
}



0



geometria

1 / 1 / 0

Регистрация: 13.01.2013

Сообщений: 130

16.11.2013, 01:25

 [ТС]

7

может у меня в манифесте что-то не так?

XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ru.lkja.fx"
    android:versionCode="1"
    android:versionName="1.0" >
 
     <uses-sdk android:minSdkVersion="7" 
                  android:targetSdkVersion="18"    />
        <application 
                android:allowBackup="true"
                android:icon="@drawable/ic" 
                android:label="@string/app_name"
                android:description="@string/description">
                <service 
                        android:name=".MainActivity"
                        android:enabled="true"
                        android:icon="@drawable/ic"
                        android:label="@string/app_name"
                        android:description="@string/description" 
                        android:permission="android.permission.BIND_WALLPAPER">
                        <intent-filter android:priority="1" >
                                <action android:name="android.service.wallpaper.WallpaperService" />
                        </intent-filter>
                        <meta-data 
                                android:name="android.service.wallpaper" 
                                android:resource="@xml/mywallpaper" />
                </service>
                <activity 
                        android:label="@string/app_name"
                        android:description="@string/description" 
                        android:name=".MainActivity" 
                       
                        android:exported="true" />
                <activity android:name="Touch"></activity>
        </application>
        
</manifest>



0



1 / 1 / 0

Регистрация: 13.01.2013

Сообщений: 130

18.11.2013, 02:54

 [ТС]

8

исходный код в архиве

Вложения

Тип файла: zip Fx.zip (4.35 Мб, 5 просмотров)



0



How to fix no activity found to handle intentYou see no activity found to handle intent when you attempt to launch an intent either to open a link or to access an app component. It’s an error message that is caused because the device is not an official android, Google Play is not supported, or it’s a rooted device. If you don’t know why you are experiencing the error, our coding experts are here to help you out!

Read on as we inspect possible reasons and also help you resolve them.

Contents

  • Why Is Your Device Showing No Activity Found To Handle Intent?
  • How To Solve This Error
    • – Example 1: No Activity Found To Handle Intent Caused by Using Wrong URL
    • – Example 2: No Activity Was Found To Handle Intent on Android
    • – Example 3: Intent Failure Due to Google Play Not Supported Device
    • – Example 4: React Native Could Not Open URL No Activity Found To Handle Intent
  • FAQs
    • – What’s an Activity and Intent?
  • Conclusion

Why Is Your Device Showing No Activity Found To Handle Intent?

Your device is showing no activity found to handle intent error due to some major reasons that are listed below:

The web browser available to the user is no longer supporting plain HTTP for external links, preferring HTTPS

  • Error due to valid URL
  • Google Play is not installed
  • Using a rooted device when launching intent
  • Using an app that is not accessible because of profile restrictions
  • Settings put into place by an administrator

The launching or call of the app may fail because of any reasons mentioned above.

How To Solve This Error

To fix this error, you will need to identify and verify the error.

There is a way to verify the error, the activity will receive the intent, call [resolveActivity ( ) ] on your intent object. If you call the resolve and the result is null, do not use the intent and, if possible, you should disable the feature that issues the intent because it is not safe. But if the result is not null, there is at least one app that can handle the intent therefore, it is safe to call startActivity ( ).

Syntax:

// Create the text message with a string
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(“text/plain”);
// Verify that the intent will resolve to an activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}

– Example 1: No Activity Found To Handle Intent Caused by Using Wrong URL

We will be considering practical examples where no activity found to handle intent error is caused by passing the wrong URL.

You can get the error if you input the wrong web address when coding, especially when inputting a web link without the HTTP:// in its beginning.

Let’s consider this error.

Intent intent = new Intent();
intent.setAction(“com.dsociety.activities.MyBrowser”);
intent.setData(Uri.parse(“www.google.com”)); // should be http://www.google.com
startActivity(intent);

Solution:

<activity
android:name=”.MyBrowser”
android:label=”MyBrowser Activity” >
<intent-filter>
<action android:name=”android.intent.action.VIEW” />
<action android:name=”com.dsociety.activities.MyBrowser” />
<category android:name=”android.intent.category.DEFAULT” />
<data android:scheme=”http” />
</intent-filter>
</activity>

– Example 2: No Activity Was Found To Handle Intent on Android

Let’s consider another error, no activity was found to handle intent (act=android.intent.action.VIEW ) when trying to install APK.

This problem is resulted because the name of the APK which is not the original one. We just have to rename back to the original name using the code snippet below:

if (Build.VERSION.SDK_INT >= 29) {
try {
// DisplayUtils.getInstance().displayLog(TAG, “download completed trying to open application::::::::” + file.getAbsolutePath());
DisplayUtils.getInstance().displayLog(TAG, “path::::” + Environment.getExternalStorageDirectory() + “/Documents”);
Intent installApplicationIntent = new Intent(Intent.ACTION_VIEW);
File file = new File(Environment.getExternalStorageDirectory() + “/Documents”, “yourfile.apk”);
if (file.exists()) {
DisplayUtils.getInstance().displayLog(TAG, “is readable:::::::::” + file.canRead());
file.setReadable(true);
installApplicationIntent.setDataAndType(FileProvider.getUriForFile(context,
BuildConfig.APPLICATION_ID + “.provider”,
file), “application/vnd.android.package-archive”);
} else {
DisplayUtils.getInstance().displayLog(TAG, “file not found after downloading”);
}
installApplicationIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
installApplicationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
installApplicationIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(installApplicationIntent);
ExitActivity.exitApplicationAnRemoveFromRecent(context);
} catch (Exception cv) {
}
}

– Example 3: Intent Failure Due to Google Play Not Supported Device

Here is another example where the error is found when launching an intent on a device where Google Play is not installed or supported.

Note: we will provide you with only the android manifest portion.

<activity android:name=”com.surreall.sixdice.Start” android:label=”Six Dice” android:screenOrientation=”portrait” android:configChanges=”keyboardHidden|orientation”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
<intent-filter>
<action android:name=”android.intent.action.VIEW” />
<category android:name=”android.intent.category.DEFAULT” />
</intent-filter>
</activity>

This code is running on an Android environment that lacks the Google Play Store, such as an emulator, Kindle Fire, etc. If you are encountering this on an emulator, test this code path on a device that has the Play Store.

If you are encountering this on some piece of hardware that lacks the Play Store or you are planning on distributing your app to devices that lack the Play Store, you should handle the exception or use PackageManager and resolveActivity() to determine if your Intent will succeed before calling startActivity().

if(intent.resolveActivity(getPackageManager()) != null)
startActivityForResult(intent, 0);
else

Another solution is to use intent.createChooser ( ) method to safely launch the intent. With this method, the user can still choose to open the intent in the play store using the following line:

startActivity(Intent.createChooser(marketIntent, “dialogTitle”));

But the better solution would be to try to open the URL in the Google Play app or open the URL in the browser.

Let’s see an example for that:

public static void rateApp(Context context) {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(“market://details?id=” + context.getPackageName())));
} catch (android.content.ActivityNotFoundException anfe) {
viewInBrowser(context, “https://play.google.com/store/apps/details?id=” + context.getPackageName());
}
}
public static void viewInBrowser(Context context, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (null != intent.resolveActivity(context.getPackageManager())) {
context.startActivity(intent); }
}

– Example 4: React Native Could Not Open URL No Activity Found To Handle Intent

Let’s try another example where we use React Native. In this example we will artificially cause an error: React Native Could not open URL No Activity found to handle Intent with possible solution.

componentDidMount()
{leturl=”intent:#Intent;action=com.squareup.pos.action.
CHARGE;package=com.squareup;
S.browser_fallback_url=https://my.website.com/index.html;S.com.squareup.pos.
WEB_CALLBACK_URI=https://my.website.com/index.html;S.com.squareup.pos.
CLIENT_ID=sq0ids-yOurCLieNtId;S.com.squareup.pos.API_VERSION=v2.0;i.com.squareup.pos.
TOTAL_AMOUNT=100;S.com.squareup.pos.CURRENCY_CODE=USD;
S.com.squareup.pos.TENDER_TYPES=com.squareup.pos.
TENDER_CARD,com.squareup.pos.TENDER_CARD_ON_FILE,com.squareup.pos.
TENDER_CASH,com.squareup.pos.TENDER_OTHER;end”;
Linking.openURL(url).catch(err => console.error(“An error occurred”, err));
}

This code will display an error message:

Could not open URL ‘intent:#Intent; … end’: No Activity found to handle Intent { act=android.intent.action.VIEW dat=intent: flg=0x10000000 }

Possible solution:

The intent:#Intent we use in the code isn’t going to work from within React Native, since it is used for going from a web browser on an Android device into the Square POS app.

The Android Web API intent is intended to do a hand-off from your browser to the Square POS application, not from application to application.

The solution is to link a native module with the React Native application.

FAQs

– What’s an Activity and Intent?

The activity is your user interface and whatever you can do with a user interface. It is just like a page when you open your app. It is a UI component that you see on your screen.

An intent is a message object which is used to request an action from the same or different app component. You can think of intent as a way (or intention) to open another activity.

Syntax:

In the simplest case, you can start new activity using this:
Intent intent = new Intent(this, SomeOtherActivity.class);
startActivity(intent);

You can use the above example to start an activity, and the activity you are starting is “intent”.

After we have inputted the above code, what we will do is to call the method startActivity ( ) by passing it to a container called intent. The container tells startActivity ( ) what to do.

Example

Let’s consider this example, you will be able to see it clearly as you are passing data to a new activity.

Intent intent = new Intent(this, SomeOtherActivity.class);
startActivity(intent);
intent.putExtra(“ANIMAL_TYPE”, “unicorn”);
intent.putExtra(“ANIMAL_COLOR”, “ruby”);
startActivity(intent);

Now you can see that you can start the activity using the instruction/code.

After you call startActivity ( ), it looks at intent and knows that it needs to start the someOtherActivity class. In the someOtherActivity class, you can access those passed key/value pairs from the intent like the following:

Bundle extras = getIntent().getExtras();
if(extras !=null) {
String animal = extras.getString(“ANIMAL_TYPE”);
String animalColor = extras.getString(“ANIMAL_COLOR”);
}

Conclusion

Now you understand why when launching intent! Let’s sum up the key points we mentioned in the article.

  • The error can be caused by not using Google Play supported device
  • There is a way to verify the error whether to continue launching the intent or not
  • The error can be caused if the web address is inputted in a wrong way
  • Using an app that is not accessible due to profile restriction can cause the error

Device showing no activity found to handle intentAfter reading the article, you should easily detect the issue and fix the problem.

  • Author
  • Recent Posts

Position is Everything

Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL. Meet The Team

Position is Everything

S

That’s how I realized later.
p.s. We’ll wait a couple of days other answers, this way has accelerated the whole procedure to 18 minutes. StringTokenizer tok = null;
try {
tok = new StringTokenizer(ebcdicToAscii(IOUtils.toByteArray(new FileInputStream(fileName))), «rn»); // сразу передаю в StringTokenizer, чтобы не хранить в памяти объект.
} catch (IOException e) {
error(«Cannot read file » + fileName);
}
while (tok.hasMoreTokens()) {
String line = tok.nextToken();
// делаешь свои дела
}
public static String ebcdicToAscii(byte[] e) {
try {
return new String(ebcdicToAsciiBytes(e, 0, e.length), «ISO8859_1»);
} catch (UnsupportedEncodingException var2) {
return var2.toString();
}
}
public static byte[] ebcdicToAsciiBytes(byte[] e, int offset, int len) {
byte[] a = new byte[len];

for(int i = 0; i &lt; len; ++i) {
a[i] = EBCDIC2ASCII[e[offset + i] &amp; 255];
}

return a;
}

public static final byte[] EBCDIC2ASCII = new byte[] {
(byte)0x0, (byte)0x1, (byte)0x2, (byte)0x3,
(byte)0x9C, (byte)0x9, (byte)0x86, (byte)0x7F,
(byte)0x97, (byte)0x8D, (byte)0x8E, (byte)0xB,
(byte)0xC, (byte)0xD, (byte)0xE, (byte)0xF,
(byte)0x10, (byte)0x11, (byte)0x12, (byte)0x13,
(byte)0x9D, (byte)0xA, (byte)0x8, (byte)0x87,
(byte)0x18, (byte)0x19, (byte)0x92, (byte)0x8F,
(byte)0x1C, (byte)0x1D, (byte)0x1E, (byte)0x1F,
(byte)0x80, (byte)0x81, (byte)0x82, (byte)0x83,
(byte)0x84, (byte)0x85, (byte)0x17, (byte)0x1B,
(byte)0x88, (byte)0x89, (byte)0x8A, (byte)0x8B,
(byte)0x8C, (byte)0x5, (byte)0x6, (byte)0x7,
(byte)0x90, (byte)0x91, (byte)0x16, (byte)0x93,
(byte)0x94, (byte)0x95, (byte)0x96, (byte)0x4,
(byte)0x98, (byte)0x99, (byte)0x9A, (byte)0x9B,
(byte)0x14, (byte)0x15, (byte)0x9E, (byte)0x1A,
(byte)0x20, (byte)0xA0, (byte)0xE2, (byte)0xE4,
(byte)0xE0, (byte)0xE1, (byte)0xE3, (byte)0xE5,
(byte)0xE7, (byte)0xF1, (byte)0xA2, (byte)0x2E,
(byte)0x3C, (byte)0x28, (byte)0x2B, (byte)0x7C,
(byte)0x26, (byte)0xE9, (byte)0xEA, (byte)0xEB,
(byte)0xE8, (byte)0xED, (byte)0xEE, (byte)0xEF,
(byte)0xEC, (byte)0xDF, (byte)0x21, (byte)0x24,
(byte)0x2A, (byte)0x29, (byte)0x3B, (byte)0x5E,
(byte)0x2D, (byte)0x2F, (byte)0xC2, (byte)0xC4,
(byte)0xC0, (byte)0xC1, (byte)0xC3, (byte)0xC5,
(byte)0xC7, (byte)0xD1, (byte)0xA6, (byte)0x2C,
(byte)0x25, (byte)0x5F, (byte)0x3E, (byte)0x3F,
(byte)0xF8, (byte)0xC9, (byte)0xCA, (byte)0xCB,
(byte)0xC8, (byte)0xCD, (byte)0xCE, (byte)0xCF,
(byte)0xCC, (byte)0x60, (byte)0x3A, (byte)0x23,
(byte)0x40, (byte)0x27, (byte)0x3D, (byte)0x22,
(byte)0xD8, (byte)0x61, (byte)0x62, (byte)0x63,
(byte)0x64, (byte)0x65, (byte)0x66, (byte)0x67,
(byte)0x68, (byte)0x69, (byte)0xAB, (byte)0xBB,
(byte)0xF0, (byte)0xFD, (byte)0xFE, (byte)0xB1,
(byte)0xB0, (byte)0x6A, (byte)0x6B, (byte)0x6C,
(byte)0x6D, (byte)0x6E, (byte)0x6F, (byte)0x70,
(byte)0x71, (byte)0x72, (byte)0xAA, (byte)0xBA,
(byte)0xE6, (byte)0xB8, (byte)0xC6, (byte)0xA4,
(byte)0xB5, (byte)0x7E, (byte)0x73, (byte)0x74,
(byte)0x75, (byte)0x76, (byte)0x77, (byte)0x78,
(byte)0x79, (byte)0x7A, (byte)0xA1, (byte)0xBF,
(byte)0xD0, (byte)0x5B, (byte)0xDE, (byte)0xAE,
(byte)0xAC, (byte)0xA3, (byte)0xA5, (byte)0xB7,
(byte)0xA9, (byte)0xA7, (byte)0xB6, (byte)0xBC,
(byte)0xBD, (byte)0xBE, (byte)0xDD, (byte)0xA8,
(byte)0xAF, (byte)0x5D, (byte)0xB4, (byte)0xD7,
(byte)0x7B, (byte)0x41, (byte)0x42, (byte)0x43,
(byte)0x44, (byte)0x45, (byte)0x46, (byte)0x47,
(byte)0x48, (byte)0x49, (byte)0xAD, (byte)0xF4,
(byte)0xF6, (byte)0xF2, (byte)0xF3, (byte)0xF5,
(byte)0x7D, (byte)0x4A, (byte)0x4B, (byte)0x4C,
(byte)0x4D, (byte)0x4E, (byte)0x4F, (byte)0x50,
(byte)0x51, (byte)0x52, (byte)0xB9, (byte)0xFB,
(byte)0xFC, (byte)0xF9, (byte)0xFA, (byte)0xFF,
(byte)0x5C, (byte)0xF7, (byte)0x53, (byte)0x54,
(byte)0x55, (byte)0x56, (byte)0x57, (byte)0x58,
(byte)0x59, (byte)0x5A, (byte)0xB2, (byte)0xD4,
(byte)0xD6, (byte)0xD2, (byte)0xD3, (byte)0xD5,
(byte)0x30, (byte)0x31, (byte)0x32, (byte)0x33,
(byte)0x34, (byte)0x35, (byte)0x36, (byte)0x37,
(byte)0x38, (byte)0x39, (byte)0xB3, (byte)0xDB,
(byte)0xDC, (byte)0xD9, (byte)0xDA, (byte)0x9F
};

Понравилась статья? Поделить с друзьями:

Не пропустите эти материалы по теме:

  • Яндекс еда ошибка привязки карты
  • Android process media произошла ошибка как исправить asus
  • Android process media произошла ошибка zte
  • Android process core ошибка
  • Android process acore произошла ошибка как исправить lenovo

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии