So I have this app, but its to big for the play store because it has lots of pdfs, so I decided to use play asset delivery to retrieve the pdfs. I have done everything like it says in google docs, I have created an asset-package, changed everything in the manifest, build.gradle and build a bundle! But the play asset delivery just isn't working! I can't get my pdf files that are on the "pdfs->src->main->assets" !! Can someone please help me? Am I choosing the right package name?
My source code to retrieve the pdf is the following :
mPDFView = (PDFView) findViewById(R.id.pdf);
Context context = null;
try {
context = createPackageContext(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
AssetManager assetManager = context.getAssets();
try {
InputStream is = assetManager.open("A abóboda.pdf");
mPDFView.fromStream(is).load();
} catch (IOException e) {
e.printStackTrace();
}
I want to create an app,that's use to only allow access specific apps in a device.So I tried to pinned the device.Now I want to open another application that is in my specific apps list.
I can't open another app while pinned.
This is the code I used to pinned
startLockTask();
and this is the code to I tried to open another appilication in kiosk mode
ComponentName deviceAdmin = new ComponentName(KioskActivity.this, MyAdmin.class);
if (myDevicePolicyManager.isDeviceOwnerApp(getPackageName()))
{
myDevicePolicyManager.setLockTaskPackages(deviceAdmin, new String[]{getPackageName(), "com.example.pan.pocmdmhelper"});
try
{
PackageManager pm = KioskActivity.this.getPackageManager();
Intent it = pm.getLaunchIntentForPackage("com.example.pan.pocmdmhelper");
it.addCategory(Intent.CATEGORY_LAUNCHER);
if (null != it) {
KioskActivity.this.startActivity(it);
Toast.makeText(KioskActivity.this, "Started activity for this package", Toast.LENGTH_SHORT).show();
}
}
catch (Exception e)
{
Toast.makeText(KioskActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
finish();
}
}
At the moment I tried to open single app by using it's package name.It's open if I unpinned only
I'm working with notifications generated by every app (not only mine) on my Android device (android 5.1.1).
By extending NotificationListenerService I'm able to know when a push notification is posted (overriding the "onNotificationPosted" method) and when a notification is removed (overriding the "onNotificationRemoved" method).
The problem is that I would like to know how the notification was removed:
a) by clicking it (so opening the app)
or
b) by swyping it (so it is only removed)
?
Is it possible to know it?
Thank you in advance!
The best way to do it is to get the list of all running processes!
So, in the onNotificationRemoved method we can:
1. obtain the list of running processes using the Android Processes library
2. compare each process name with the packageName
3. if the comparison return a true value, we check if the process is in foreground
public void onNotificationRemoved(StatusBarNotification sbn) {
String packageName = sbn.getPackageName();
try {
List<AndroidAppProcess> processes = ProcessManager.getRunningAppProcesses();
if (processes != null) {
for (AndroidAppProcess process : processes) {
String processName = process.name;
if (processName.equals(packageName)) {
if (process.foreground ==true)
{
//user clicked on notification
}
else
{
//user swipe notification
}
}
}
}
}
catch (Exception e)
{
String error = e.toString();
}
}
I'm trying to connect to .NET 4.0 webservice I created for receiving SOAP-calls from Android-devices, now hosted on local IIS for testing purposes.
I found out that ksoap2 would be an excellent class library for doing what i want to do. Downloaded the .jar package from https://code.google.com/p/ksoap2-android/ and started pounding the keyboard in ecstacy... with my fingers.
The amount of information being sent is from few kilobytes to few megabytes.
What is working
HttpTransportSE.call(String, SoapSerializationEnvelope)-method works perfectly while still in Eclipse's Android emulator, sending the call to webservice hosted in local IIS. Even tested that the webservice receives empty calls from trying to open the service address from a web browser in the same local area network.
What doesn't work
When I copy the .apk-file to an Android device, install it, start it and trying to make the call, the whole program freezes without making the call.
As you can see from a code block presented some lines after that possible errors are being taken into account: In emulated environment a successful call returns a SoapPrimitive-object or flows into the correct catch block generating an error message for the user according to the current situation.
Then on live Android device, program loses it's responsivity forever and has to be terminated from application menu.
What have i tried
I removed the call from the asynchronous method, and tried calling it straight from an anonymous inner function assigned for a button click-event.
Tried not trying to get a response, just making the call.
Tried getting a logcat-program for the device to see what's happening behind the UI, found two, they needed root access, which i don't have in the device. This is why i don't have any logcats to show you, and showing the emulator logcat would probably(?) be useless because it works fine there.
Not trying to connect to localhost.
Tried installing the program on older Lenovo-tablet running Android 4.2.2 and on brand new Samsung Galaxy Tab, both would have the same problem while otherwise working well.
The code
Here's the asynchronous method for making the call in device/emulator, where variables str_URL and soapRequest are a correct service address (checked) and a well formed SoapObject respectively:
#Override
protected WebServiceResult doInBackground(Void... v) {
WebServiceResult _ret;
SoapSerializationEnvelope soapEnvelope= new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet=true;
soapEnvelope.setAddAdornments(false);
soapEnvelope.setOutputSoapObject(soapRequest);
HttpTransportSE conn = new HttpTransportSE(str_URL);
conn.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
conn.debug = true;
try {
conn.call(str_ACTION, soapEnvelope);
SoapObject o = (SoapObject)soapEnvelope.getResponse();
_ret = new WebServiceResult(o, WebServiceResultEnum.ok);
} catch (NetworkOnMainThreadException e) {
_ret = new WebServiceResult(null, WebServiceResultEnum.keskeytys);
} catch (HttpResponseException e) {
_ret = new WebServiceResult(null, WebServiceResultEnum.httpVirhe);
} catch (XmlPullParserException e) {
_ret = new WebServiceResult(null, WebServiceResultEnum.vaara_muoto);
} catch (SocketTimeoutException e) {
_ret = new WebServiceResult(null, WebServiceResultEnum.aikakatkaisu);
} catch (Exception e) {
_ret = new WebServiceResult(null, WebServiceResultEnum.keskeytys);
}
return _ret;
}
Thank you in advance!
Is it possible you are doing something like this:
YourAsyncTask task = new YourAsyncTask();
WebServiceResult result = task.doInBackground();
Because that would be wrong, completely wrong. If you call doInBackground() directly it will run in the same Thread and not in a new one. You need to start the AsyncTask with execute() like this:
YourAsyncTask task = new YourAsyncTask();
task.execute();
You need to implement the AsyncTask like this:
public class ExampleTask extends AsyncTask<Void, Void, WebServiceResult> {
public interface FinishedListener {
public void onFinished(WebServiceResult result);
}
private final FinishedListener finishedListener;
public ExampleTask(FinishedListener listener) {
this.finishedListener = listener;
}
#Override
protected WebServiceResult doInBackground(Void... params) {
WebServiceResult result = ...;
return result;
}
#Override
protected void onPostExecute(WebServiceResult result) {
super.onPostExecute(result);
if(this.finishedListener != null) {
this.finishedListener.onFinished(result);
}
}
}
And if you implemented it that way you can use it like this:
ExampleTask task = new ExampleTask(new ExampleTask.FinishedListener() {
#Override
public void onFinished(WebServiceResult result) {
// This will be called if the task has finished
}
});
task.execute();
It seems that I had declared the minimum SDK as 14 and target SDK as 17 in AndroidManifest.xml. I didn't use any fancy things in newer sdk's so i lowered the target SDK to the same level as minimum SDK, 14. I also had an Avast! Antivirus service running on the tablet which i removed.
This solved my problem. It could be that probably the Avast! antivirus-program wanted to block all communications from applications not downloaded from Play-store. I don't know if changing the target SDK had much effect really.
Well, I had the same question as you. When it goes to the method transport.call, it pauses, and for a while, it throws a timeout problem. At first, I thought maybe the network was poor, but the server logcat shows it is not the problem. The request was fine and the response was good. My business process is like below:
First, I get a list from the server through ksoap inner a child thread, then cycle the list, send a ksoap request based on every item of the list. It means it will send another list.size() request. When debugging in a real device the above problems occured. I solved it by starting a new child thread after getting the list and making all the list.size requests in the new child thread. So, ksoap use in android may cause thread block which leads to ioexception. So when you put it in a new thread, it escapes from the parent catch exception and works fine.
Currently working on a Android application for delivery drivers. Its been working fine for months but now it suddenly force quits when 'submit' button is pressed.
Whilst debugging its given me all sorts of run time errors relating to the android library.
When I go to the exact location each one says Source not found. Everything is there as it should be and I've reinstalled the SDK and been through every file location.
Please Help
Edit:
if(isOnline())
{
PODCache.clearedfordeliveryjobs.add(etDespatch.getText().toString());
new runner().execute(al_kvp);
}
PODCache is another class this is the bit the above is referring too.
public void onStart(Intent intent, int startid) {
// Run this
Toast.makeText(getApplicationContext(), "PODCache Started", 10).show();
RUNNING = true;
try {
clearedfordeliveryjobs = (ArrayList<String>) LocalPersistence
.readObjectFromFile(this, UNBLOCKEDLIST);
} catch (Exception e) {
clearedfordeliveryjobs = new ArrayList<String>();
}
What is keypod.keyfort.net.PickUpActivity? Have you tried finding that class? That does not look like a standard Android to me.