Android camera and web resolution

On Android, I remember that it was mandatory to request permission to use the camera or access the internet in the app.

But I did a little test where I didn't ask for any of the above permissions and I expected my test app to crash and burn.

But that did not happen!!

I was able to use the camera and access the internet without asking for permissions and I tested on 3 devices, all with different versions of Android.

Here is the code:

public class MainActivity extends Activity implements View.OnClickListener
{
    private int cameraCode = 0;
    private Button start_cam;
    private Button start_internet;

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

        start_cam = (Button) findViewById(R.id.camera);
        start_internet = (Button) findViewById(R.id.internet);

        start_cam.setOnClickListener(this);
        start_internet.setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
        switch(v.getId())
        {
            case R.id.camera:
                Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(intent, cameraCode);
                break;
            case R.id.internet:
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com"));
                startActivity(browserIntent);
                break;
        }
    }
}

      

manifesto:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.permissions.linux.android">

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="16" />

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">

        <activity
            android:name="com.permissions.linux.androi.android.MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


    </application>

</manifest>

      

The question is, why didn't he fall?

+3


source to share


1 answer


I was able to use the camera and access the internet without asking for permissions



No, you weren't. You may have asked other applications to "use the camera and access the Internet" on your behalf. Your application did not directly use the camera and your application did not get direct access to the Internet. For other applications, to which you are attached, you need permission CAMERA

and INTERNET

to carry out their tasks. Sometimes, you may need a certain permission even to get a third-party application to do something for you that you don't have to take a picture or browse the web page.

+3


source







All Articles