How to start activity through my app in another app? - java

I am very new to writing android app, I am trying to start specific activity from an other app (App B)through my app (App A). I know how to launch the App B but I need App B do some specific task with a click of button without showing the launching process I just want to jump to that task(like playing music with out showing the introduction and starting part of App B).
This is part of App A , the place I want to do specific task from App B instead of just launching it. ( even maybe I don't need to launch it )
public void playOn(View view) {
ImageButton sound = (ImageButton) findViewById(R.id.musicButton);
if (lightt) {
sound.setImageResource(R.drawable.play_dn);
lightt = false;
} else {
sound.setImageResource(R.drawable.play_up);
lightt = true;
}
Intent intent = getPackageManager().getLaunchIntentForPackage("com.Zample.RUNiBplayMusic");
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
and this is part of App B that I have access to
<application android:icon="#drawable/ic_launcher" android:label="Bplay Music" android:name="com.Zample.RUNiBplayMusic.Common.App" android:theme="#style/AppTheme">
<activity android:launchMode="singleTask" android:name=".StartActivity" android:screenOrientation="portrait">
<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"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="com.bplaymusicwifi" android:scheme="bplaymu"/>
</intent-filter>
</activity>
<activity android:finishOnTaskLaunch="true" android:name=".HelpListActivity" android:screenOrientation="portrait"/>
<activity android:launchMode="singleTask" android:name=".DeviceListActivity" android:screenOrientation="portrait"/>
<activity android:finishOnTaskLaunch="true" android:name=".PlayModeActivity" android:screenOrientation="portrait"/>
<activity android:finishOnTaskLaunch="true" android:name=".HelpListActivity" android:screenOrientation="portrait"/>
<receiver android:label="Bplay Music" android:name=".AppWidget.AppWidgetSmall">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<receiver android:label="Bplay Music" android:name=".AppWidget.AppWidgetBig">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="#xml/widget_info_big"/>
</receiver>
<service android:name=".AppWidget.Bplay MusicService"/>
<service android:name=".Record.RecordService"/>
</application>
I think this part of the code from App B might help me. but I am not sure.
I hope you can help me how to solve this issue.

Related

How to change Activity Priority in Android Studio

Iam trying to add Splash screen to my existing Android Project, which is not MainActivity.Java, but by default Android Studio is executing MainActivity.Java first, So I want to change the Activity Priority so that my SplashActivity.Java will execute first and later Activity's will follow after the Splash Screen.
Make splash activity your launcher activity instead of Main Activity in Android Manifest.
<activity
android:name=".ui.splash.SplashActivity"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
modify your AndroidManifest.xml like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.circlefil.reactivetrip">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"/>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
You need to add IntentFilter in you splash screen activity and from splash screen activity you have to link your main activity using Intent.
Add following code to your splash screen activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
How ever keeping an entire activity is not the best way to create splash screen. See this for more info: Here
To Start activity first you need to make it Launcher Activity in AndroidManifest.xml file.
<activity
android:name=".StartingActivityName">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

error: cannot find symbol class AdvertiseActivity

I'm new to Android app development so please be patient with me. I'm writing an app that gets the GPS location from Google Play services and then broadcasts the data over Bluetooth. I have a LocationActivity that gets the location, and an AdvertiseActivity that broadcasts the data.
My problem is that I'm having a hard time understanding the file structure in android apps, so I suspect my lack of understanding is why I'm getting the error.
Here is a snippet of LocationActivity where the error is:
#Override
public void onLocationReceived(Location location) {
Intent i = new Intent(LocationActivity.this, AdvertiseActivity.class) //problem is here
.putExtra("latitude", location.getLatitude());
startActivity(i);
}
Why can't the compiler find AdvertiseActivity.class? Is something wrong with my manifest below?
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name="com.android.app.LocationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.android.app.AdvertiseActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Please help. Thanks!
You are using two activities as MAIN .From manifest, Remove:
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DEFAULT" />
From AdvertiseActivity's activity tag. Hope this helps.
Remove these lines from manifest
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
And keep only this line.
<activity android:name="com.android.app.AdvertiseActivity"/>
An Application can have only one android.intent.action.MAIN in Startup Activity. In your LocationActivity you already defined so remove intent-filter from AdvertiseActivity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
so its like
<activity android:name="com.android.app.AdvertiseActivity"/>

Android 6.0 Broadcast Receiver don't receive BOOT_COMPLETE

My receiver is not working with Android 6.0 Marshmallow.
I am sending a broadcast through adb shell, see below:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED received
if application was open, App say:Working!
But if the application was not open, it has not been returning anything.
My code is here;
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.berate.rebootreceiverfromb3r0">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" android:protectionLevel="signature|development"></uses-permission>
<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" />
</intent-filter>
</activity>
<receiver android:name="com.example.berate.rebootreceiverfromb3r0.Yakala_Receiver">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"></category>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>
</manifest>
Receiver.Java;
public class Yakala_Receiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"i got it ",Toast.LENGTH_SHORT).show();
}
}
Edit: I have very interesting info, My code is working on samsung (Android 6.0) devices. But my (Android 6.0) devices not responding me
change this
<receiver android:name="com.example.berate.rebootreceiverfromb3r0.Yakala_Receiver">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"></category>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
to this
<receiver android:name="com.example.berate.rebootreceiverfromb3r0.Yakala_Receiver" android:enabled="true" android:exported="true">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"></category>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
hope it helps
I fixed, some new android devices have security application by default. some times these apps lock your auto-start mode.

Android: wrong arguments on intent

I've got problems with using the Intent object of Android.
I'm basically trying to launch another activity:
My Activity, MapActivity, makes use of a MapEventListener, which provides functions to listen to events based on a map which is rendered in the MapActivty Activity. If a marker is pressed on the map, a function of the MapEventListener is Launched.
I this function I'm trying to implement an Intent object which launches another activty.
This is the function's code:
#Override
public void onVectorElementClicked(VectorElement arg0, double arg1,
double arg2, boolean arg3) {
Intent intent = new Intent(MapActivity.this, DetailPerspectiveActivity.class);
activity.startActivity(intent);
}
This is the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.hsrw.landschaftsbilder"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/><application android:icon="#drawable/icon" android:label="#string/app_name" android:allowBackup="false">
<activity android:name=".activities.MapActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".activities.GraphhopperRouteTestActivity">
</activity>
<activity android:name=".activities.DetailPerspectiveActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
I'm pretty sure the problem is about "MapActivity.this" but if I change this to MapActivity.this in the manifest the code is still not compilable. That's what eclipse says about the first argument:
No enclosing instance of the type MapActivity is accessible in scope
Thanks in advance!
In your activity, try to change Intent intent = new Intent(.activities.MapActivity.this, .activities.DetailPerspectiveActivity.class); to Intent intent = new Intent(MapActivity.this, DetailPerspectiveActivity.class); (ie. both MapActivity and DetailPerspectiveActivity).
Your manifest.xml file contains problems. you have declared two activities as launcher which will not work
amend manifest.xml code as following.
Instead of following
<activity android:name=".activities.MapActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".activities.GraphhopperRouteTestActivity">
</activity>
<activity android:name=".activities.DetailPerspectiveActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Use the following code
<activity android:name=".activities.MapActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".activities.GraphhopperRouteTestActivity">
</activity>
<activity android:name=".activities.DetailPerspectiveActivity">
</activity>
Edit:
What does this line do in your code.
Intent intent = new Intent(.activities.MapActivity.this, .activities.DetailPerspectiveActivity.class);
It usually is the following way
Intent intent = new Intent(FIRST_ACTIVITY.this, SECOND_ACTIVITY.class);
in your case I presume it should be
Intent intent = new Intent(MapActivity.this, DetailPerspectiveActivity.class);

Android app not showing in "All Apps"

After some changes I made to my app that I made so it would show the activities in a different order, the app icon no longer appears in the "All Apps" screen on the android device. It does, however, show up on the "Recent" screen. I think it has something to do with a configuration error in my manifest file. I would like the ServerChoiceActivity to be the one represented by the icon, and it's what launches when launch it from the recent screen, but the fact that there is no icon on the "All apps" or "Downloaded" pages confuses me quite a bit.
The application section of my manifest file:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true">
<activity android:name=".ServerChoiceActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<data android:mimeType="image/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".ServerSettingsActivity" android:screenOrientation="portrait" android:label="#string/settings_title">
<intent-filter>
</intent-filter>
</activity>
<activity
android:name=".ImageShareActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="image/*"/>
</intent-filter>
</activity>
<activity
android:screenOrientation="portrait"
android:name=".MultiImageUploadActivity"
android:taskAffinity="test.affinity"
android:label="#string/multiupload_title">
<intent-filter>
</intent-filter>
</activity>
<activity
android:screenOrientation="portrait"
android:taskAffinity="test.affinity"
android:noHistory="true"
android:label="Bucket"
android:name=".BucketActivity">
<intent-filter>
</intent-filter>
</activity>
</application>
Any suggestions? The app works as expected when I launch it, and it was working fine, including showing the icon before I modified the manifest file.
Possibly because you have this in your ServerChoiceActivity intent-filter:
<data android:mimeType="image/*"/>

Categories