Calling an activity from class PintService

DropVid77

New member
Nov 28, 2022
1
0
0
Visit site
I created a class that extends PrintService .

I use the system dialog to print , everything is fine I see the service in print.

In onPrintJobQueued method I have this :
@override
protected void onPrintJobQueued(PrintJob printJob) {
printJob.start();

Log.d(TAG, "queued: " + printJob.getInfo());

Intent i = new Intent(getApplicationContext(), PdfWiever.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String file = "file:///storage/emulated/0/Download/"+printJob.getDocument().getInfo().getName();
i.putExtra("data", file);
try {
printJob.complete();
Log.d(TAG, "queued: " + printJob.getInfo());
startActivity(i);
}catch (Exception e){
e.printStackTrace();
}

}
I'm not getting any errors in both stackTrace and logcat. It's just that the business doesn't open.

I've seen other answers but I'm confused, in some I've read that there is a need for an interface to communicate between service and activity.

Or am I getting my intent call wrong?

I state that my activity is not running it is the service that must call it and put it into execution.

my AndroidManifest :

<activity
android:name="soget.com.it.bluetooth.sdk.PdfWiever"
android:exported="true"
android:label="SogetServizioStampa">
<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:mimeType="application/pdf" android:scheme="file" />
<data android:scheme="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/pdf" android:scheme="file" />
<data android:scheme="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/pdf" android:scheme="file" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/pdf" android:scheme="file" />
<data android:mimeType="*/*" android:scheme="mailto" />
</intent-filter>
</activity>
<service
android:name="soget.com.it.bluetooth.sdk.PdfPrint"
android:permission="android.permission.BIND_PRINT_SERVICE">
<intent-filter>
<action android:name="android.printservice.PrintService" />
</intent-filter>
</service>
Can you direct me for a solution?
 

B. Diddy

Senior Ambassador
Moderator
Mar 9, 2012
165,541
4,675
113
Visit site
Welcome to Android Central! I moved this to the Software Development forum for more specific traffic.