Implicit Internal Intent vulnerability. Can't set package name - java

I have that vulnerability according to google play console.
It's supposed that the solution is to add .setPackage() or .setClassName() to the intent but now the activity is not being recognized. How can I use this function?
The intent as it was with the vulnerability is this:
#Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent("independent.dev.ui.mainactivity");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
The solution that I tried adding the package name:
#Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent("independent.dev.ui.mainactivity");
intent.setPackage("independent.dev.ui.Activities");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
my AndroidManifest.xml is this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="independent.dev.ui.Activities">
.
.
.
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="Menu Principal"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="independent.dev.ui.mainactivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
How can I set the package so I can navigate and delete this vulnerability?

Related

android.content.ActivityNotFoundException: No Activity found to handle Intent

please help , when i run the app, the app launch a Fatal Error im learning
just i create a instat with a call but not run, (sorry for my english)
.......................................................................
my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.octa.appprueba3">
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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" />
<category android:name="android.intent.category.APP_CONTACTS" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
</application>
</manifest>
my code:
public class SecondActivity extends AppCompatActivity {
private EditText editPhoneText;
private ImageButton imageCallButton;
private final int PHONE_CALL_CODE = 100;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
editPhoneText = (EditText) findViewById(R.id.editTextPhone);
imageCallButton = (ImageButton) findViewById(R.id.imageCallButton1);
imageCallButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
implicito();
}
});
}
public void implicito(){
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("Tel: 9999999" ));
startActivity(intent);
}
}
You may want to check whether your device can handle your intent by doing this:
PackageManager packageManager = getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent);
} else {
Log.d(TAG, "Cannot handle this intent");
}
What's more, if you are placing a call like so, there is NO need to declare the permission in your manifest:
<uses-permission android:name="android.permission.CALL_PHONE" />
Because you are not directly calling someone within your app. You are actually transferring the "duty" to other apps which can handle your intent to call. This doesn't need a permission.
To directly make a call within your app, the intent should be Intent.ACTION_CALL, which needs the permission you declared.
Hope this will help.
There is no activity on your device that handles ACTION_DIAL for a Tel: scheme. Try:
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:9999999" ));
Case and whitespace are important when assembling a Uri.
Also note that even my revised Intent will not work on all devices, such as on an Android tablet that lacks a dialer.

How to start another activity after a splash screen in android studio

Hi everyone I'm studying now and developing a app in android studio. My problem is i can't proceed to my log in activity after splash screen. I already look in the net and stackoverflow and applied it, but still same error. I appreciate for the help and answer.
Here are some of my code
SplashScreen.java
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
final Intent mainIntent = new Intent(SplashScreen.this, Login.class);
SplashScreen.this.startActivity(mainIntent);
SplashScreen.this.finish();
}
},3000);
}
Login.java
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
finish();
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/logo"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SplashScreen"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".Login"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Login"/>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="com.ex.app.MainActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
where did i go wrong ?
As you have written code to move to MainActivity on the method onCreate of Login.java
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
finish();
Comment this line or keep it on the click of SignIn button
Your login activity just directs you to the MainActivity on create
Look at these lines
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
It is redirecting to MainActivity directly as in your LoginActivity onCreate you have written
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
finish();
without any condition. Make it conditional by putting your login check conditions and criteria
if (<logged_in_your_condition_Check>){
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
finish();
}
why you require below lines in Login.class
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
finish();
if you are using finish() in onCreate() then it will immediately called onDestroy() and that dosen't make any sense.
remove above given code from onCreate your code will work
in manifest write:
<activity
android:name=".MySplashActivity"
android:noHistory="true"
..... >
....
</activity>
then in create() or somewhere different cal the method:
private static int SPLASH_TIME_OUT=2000;
private void nextScreen() {
new Handler().postDelayed(()-> {
Intent intent = new Intent(MySplashaActivity.this, NextActivity.class);
startActivity(intent);
finish();
}, SPLASH_TIME_OUT);
}

How to create an android app that is set to default when the device is turned on

I want to create an application in android , which after installation I need to set as default when ever the device is turned on .
I have tried the following
created a service ,
created a reciever to recieve boot completion event
It is not working actually.If I remove the launcher for MainActivity the it will show error saying
No Launcher activity found!
The launch will only sync the application package on the device!
my manifest file
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".MyService"
android:label="My Service" >
<intent-filter>
<action android:name="com.example.splash_test.MyService" />
</intent-filter>
</service>
<receiver
android:name=".receiver.MyReceiver"
android:label="MyReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="com.example.splash_test.Screen1"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
</activity>
</application>
MyReceiver.java
public class MyReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent serviceIntent = new Intent(context, MyService.class);
context.startService(serviceIntent);
}
}
}
MyService.java
public class MyService extends Service {
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(i);
}
return null;
}
}
You have to follow below steps for achieve this task:-
Make a service in your app(Run all time).
check your app is running or not in service.(Through package name)
if running then good other wise run with the help of service.
Try it.... its working fine in my app. :)

ImageButton not responding

What I am attempting to do is to open "Items" when the ImageButton "ibItem1" is pressed. But, after setting up this:
ibItem1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent items = new Intent("android.intent.action.ITEMS");
startActivity(items);
}
});
And clicking the button does not do anything. I have the activity all set up in the manifest:
<activity
android:name="com.example.custombuilds.Items"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.ITEMS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
The program has crashed before because of a ActivityNotFoundException, even though I declared it in the manifest.
Intent myIntent = new Intent(this, NextActivity.class);
startActivity(myIntent);
In this form, it should work..
Also make sure that the name of the class that implements the activity is the same in the manifest file at the android:name="atributevalue".The attribute value should be a fully qualified class name.

Change page via BroadcastReceiver does not work

I am trying to make a second page show up via a BroadcastReceiver, but the App keeps crashing and I don't know why.
This might be a problem of the correct context.
public class ScreenReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
Log.v("$$$$$", "In Method: ACTION_SCREEN_OFF");
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
Log.v("$$$$$", "In Method: ACTION_SCREEN_ON");
changeActivity(context);
} else if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
Log.v("$$$$$", "In Method: USER_PRESENT");
}
}
public void changeActivity(Context context) {
Intent intent = new Intent(context, Second_Page.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(intent);
}
}
My Manifest. In there I declare the class that the log file states is missing:
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".CatchUnlockActivity"
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="second_page" >
</activity>
</application>
</manifest>
Found the solution:
The declaration of the classes is case-sensitive!
Changed every occurrence from "second_page" to "Second_Page" and now it works.

Categories

Resources