[Q] Problems with installing - Firefox OS General

I got problem when i want to install my first application for firefox os. I just wanted to figure out how is installing apps working. So i coded some test pages and create a manifest file. The problems is when i want to install my app from url (blabla.com/install.html) then the error message pop up "INVALID_MANIFEST". But when i put my manifest in emulator, then works... but if i want to install with install.html then shows error msg.
manifest
Code:
{
"name": "My App",
"description": "This is testing application",
"launch_path": "srpskaitedukacija .org/app/index.html",
"icons": {
"128": "/img/icons/mortar-128.png"
},
"developer": {
"name": "Venom",
"url": "srpskaitedukacija.org"
},
"default_locale": "en"
}
Install.html
Code:
<html>
<body>
<p>Aplikacija</p>
<script>
var manifestUrl = "srpskaitedukacija .org/app/manifest.webapp";
var req = navigator.mozApps.installPackage(manifestUrl);
req.onsucces = function(){
alert(this.result.origin);
};
req.onerror = function(){
alert(this.error.name);
};
</script>
</body>
</html>
by the way i put the line in .htacces for running .webapp
Pls help

Related

Windows Mobile SendSMS

I'm trying to send out a generic message using SENDSMS function in Windows Mobile Sample Code but I am unsuccessful. Here is a copy of the code
Code:
// ***************************************************************************
// Function Name: SendSMS
//
// Purpose: Send an SMS Message
//
// Arguments: none
//
// Return Values: none
//
// Description:
// Called after everything has been set up, this function merely opens an
// SMS_HANDLE and tries to send the SMS Message.
void SendSMS(BOOL bSendConfirmation, BOOL bUseDefaultSMSC, LPCTSTR lpszSMSC, LPCTSTR lpszRecipient, LPCTSTR lpszMessage)
{
SMS_HANDLE smshHandle;
SMS_ADDRESS smsaSource;
SMS_ADDRESS smsaDestination;
TEXT_PROVIDER_SPECIFIC_DATA tpsd;
SMS_MESSAGE_ID smsmidMessageID;
// try to open an SMS Handle
if(FAILED(SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL)))
{
MessageBox(NULL,
(LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSOPEN, 0, 0),
(LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 0, 0),
MB_OK | MB_ICONERROR);
return;
}
// Create the source address
if(!bUseDefaultSMSC)
{
smsaSource.smsatAddressType = SMSAT_INTERNATIONAL;
_tcsncpy(smsaSource.ptsAddress, lpszSMSC, SMS_MAX_ADDRESS_LENGTH);
}
// Create the destination address
smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;
_tcsncpy(smsaDestination.ptsAddress, lpszRecipient, SMS_MAX_ADDRESS_LENGTH);
// Set up provider specific data
memset(&tpsd, 0, sizeof(tpsd));
tpsd.dwMessageOptions = bSendConfirmation ? PS_MESSAGE_OPTION_STATUSREPORT : PS_MESSAGE_OPTION_NONE;
tpsd.psMessageClass = PS_MESSAGE_CLASS1;
tpsd.psReplaceOption = PSRO_NONE;
tpsd.dwHeaderDataSize = 0;
// Send the message, indicating success or failure
if(SUCCEEDED(SmsSendMessage(smshHandle, ((bUseDefaultSMSC) ? NULL : &smsaSource),
&smsaDestination, NULL, (PBYTE) lpszMessage,
_tcslen(lpszMessage) * sizeof(TCHAR), (PBYTE) &tpsd,
sizeof(TEXT_PROVIDER_SPECIFIC_DATA), SMSDE_OPTIMAL,
SMS_OPTION_DELIVERY_NONE, &smsmidMessageID)))
{
MessageBox(NULL,
(LPCTSTR)LoadString(ghInstance, IDS_SMSSENT, 0, 0),
(LPCTSTR)LoadString(ghInstance, IDS_CAPTION_SUCCESS, 0, 0),
MB_OK);
}
else
{
MessageBox(NULL,
(LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSSEND, 0, 0),
(LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 0, 0),
MB_OK | MB_ICONERROR);
}
// clean up
VERIFY(SUCCEEDED(SmsClose(smshHandle)));
}
Again, I am trying to explicitly specify the recipient and the message being sent which are variables LPCTSTR lpszRecipient and LPCTSTR lpszMessage. Every time I assign them a string value, I get an error. Does anybody know a solution?
Not sure
Not too sure what you are trying to achieve here, as Vijay already has an SMSSend app, which is command line driven and works a treat. Would hate for you to reinvent the wheel - check his tools out: http://www.vijay555.com/?Releases:VJPhoneTools

List files in data/data/

Code:
if(RootTools.isAccessGiven(){
List<String> SnapList;
File file;
ListView ListView = (ListView) findViewById(R.id.SnapList);
SnapList = new ArrayList<String>();
String directory = "/data/data/";
file = new File(directory);
File list[] = file.listFiles();
for( int i=0; i< list.length; i++)
{
SnapList.add( list[i].getName() );
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, SnapList);
ListView.setAdapter(adapter);
}
}
I'm trying to list the folders in /data/data in a ListView (SnapList) but this code doesn't work and my logcat in eclipse isn't working.
Can anyone shed some light? Thanks.
Chalky94 said:
Code:
if(RootTools.isAccessGiven()[COLOR="Red"])[/COLOR]{
List<String> SnapList;
File file;
ListView ListView = (ListView) findViewById(R.id.SnapList);
SnapList = new ArrayList<String>();
String directory = "/data/data/";
file = new File(directory);
File list[] = file.listFiles();
for( int i=0; i< list.length; i++)
{
SnapList.add( list[i].getName() );
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, SnapList);
ListView.setAdapter(adapter);
}
}
I'm trying to list the folders in /data/data in a ListView (SnapList) but this code doesn't work and my logcat in eclipse isn't working.
Can anyone shed some light? Thanks.
Click to expand...
Click to collapse
First of all, a bracket is missing (red one).
You need to do any root action using a Linux shell. You can execute Linux command line things from that.
For your needs this would be:
Code:
su
ls /data/data
You can do that using RootTools. For that, read these instructions: http://code.google.com/p/roottools/wiki/Usage
Then parse the output.

[Q] How download file in internal storage?

Hello, I want to download a xml file in local storage that I will parse.
The code is this
URL website = new URL("http://juventus.com/rss/news/ita.xml");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(c.getFilesDir()+"/eng.xml");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
This is called in doInBackground() of a AsyncTask class.
I get this error:
08-01 22:17:40.061: E/AndroidRuntime(9002): java.lang.RuntimeException: An error occured while executing doInBackground()
08-01 22:17:40.061: E/AndroidRuntime(9002): Caused by: java.lang.IllegalArgumentException: position=0 count=9223372036854775807
08-01 22:17:40.061: E/AndroidRuntime(9002): at java.nio.FileChannelImpl.transferFrom(FileChannelImpl.java:359)
What I do wrong?
I also tried this:
URL website = new URL("http://juventus.com/rss/news/ita.xml");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = c.openFileOutput("eng.xml", Context.MODE_PRIVATE);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
Hope you help me.
Thanks!
Try this...
Code:
URLConnection conn;
Log.d(TAG, "onDownload....path is: " + path);
try {
URL url = new URL(path);
conn = url.openConnection();
contentLength = conn.getContentLength();
DataInputStream in = new DataInputStream(conn.getInputStream());
Log.d(TAG, "Buffering the received stream(size=" + contentLength);
if (contentLength != -1) {
buffer = new byte[contentLength];
in.readFully(buffer);
in.close();
}else{
result = false;
return;
}
if (buffer.length > 0) {
Log.d(TAG,
"onDownload. Writing file to files dir,");
DataOutputStream out;
FileOutputStream fos = context.openFileOutput(fileName,
Context.MODE_PRIVATE);
Log.d(TAG, "Writing from buffer to the new file.." + fileName);
out = new DataOutputStream(fos);
out.write(buffer);
out.flush();
out.close();
result = true;
Edit: Here I am returning a boolean to indicate successful download.

[Q] External process with ProcessBuilder

I wrote a simple application that needs to run external programs as superuser. I run this piece of code in a periodic task: the code is contained in a Runnable that runs periodically by using a ScheduledThreadPoolExecutor. The code works well for a while, but after some times it stops to work randomly. To do that I used the following code. By debugging the application I found the problem is in the line Process process = builder.start();
I mean that when the problem happens the execution wait the return of this method forever.
Code:
//Code in run() Method of a class that implemnst Runnable:
ArrayList<String> results = new ArrayList<String>();
try {
ProcessBuilder builder = new ProcessBuilder("su");
builder.redirectErrorStream(true);
Process process = builder.start();
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
BufferedReader bRes = new BufferedReader(new InputStreamReader(
process.getInputStream()));
os.writeBytes("busybox ifconfig | busybox grep 'eth'; echo done_done\n"); //<-- this is my command for now
os.flush();
String r;
long curr = System.currentTimeMillis();
while ((r = bRes.readLine()).equals("done_done") == false){
results.add(r);
}
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
//...
}
Any suggestions? I can't figure out what kind of problems produce this situation. I used this code in past without problems. Can the command line "busybox ifconfig | busybox grep 'eth'; echo done_done\n" not return and works forever? I don't think so..
Thank you, Nico

Permission Denial when reading URI after RESTARTING the app

Hello everyone, I have an Android application that allows users to choose a photo for their profile as follows:
public void pickImage(View view) {
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {pickIntent});
startActivityForResult(chooserIntent, 1);
}
@override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Context context = getApplicationContext();
if (requestCode == 1 && resultCode == Activity.RESULT_OK) {
if (data == null) {
//Display an error
return;
}
try {
ImageView im = findViewById(R.id.circularImageView);
uri = data.getData();
im.setImageURI(uri);
String image = uri.toString();
Log.d("ImageS", image);
SqlHelper db = new SqlHelper(this);
Intent i = getIntent();
String userid = i.getStringExtra("Name");
db.updateImage(userid, image);
}catch (Exception e){
}
//Now you can do whatever you want with your inpustream, save it as file, upload to a server, decode a bitmap...
}
}
Everything works fine and when I want to retrieve from my db the image everything works fine:
ImageView im1 = findViewById(R.id.circularImageView2);
im1.setImageURI(null);
String iS = db.getImage(name);
Log.d("ImageR", iS);
//
// Uri uri = Uri.parse(image);
//Log.d("Equals", String.valueOf(iS.equals(String.valueOf(R.drawable.imageuser))));
if(iS.equals(String.valueOf(R.drawable.imageuser))){ //Part to determine whether the user changed it or I use the default one
im1.setImageResource(Integer.parseInt(iS));
}else{
Uri uri = Uri.parse(iS);
ContentResolver contentResolver= getContentResolver();
ParcelFileDescriptor parcelFileDescriptor = null;
try {
parcelFileDescriptor = contentResolver.openFileDescriptor(uri, "r");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
try {
parcelFileDescriptor.close();
} catch (IOException e) {
e.printStackTrace();
}
im1.setImageBitmap(image);
}
The thing is that when I restart the application, I get the following error when going into an activity in which a user changed the image:
FATAL EXCEPTION: main
Process: com.example.arturopavon.finalproject, PID: 1445
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.arturopavon.finalproject/com.example.arturopavon.finalproject.MainActivity}: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{47cb71a 1445:com.example.arturopavon.finalproject/u0a294} (pid=1445, uid=10294) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{47cb71a 1445:com.example.arturopavon.finalproject/u0a294} (pid=1445, uid=10294) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.os.Parcel.readException(Parcel.java:2004)
at android.os.Parcel.readException(Parcel.java:1950)
at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:4827)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5843)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2526)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1783)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1396)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1249)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1102)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1056)
at com.example.arturopavon.finalproject.MainActivity.onCreate(MainActivity.java:126)
at android.app.Activity.performCreate(Activity.java:7026)
at android.app.Activity.performCreate(Activity.java:7017)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
I have permissions set for my app to read internal storage but it is like it is not working after rebooting.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.MANAGE_DOCUMENTS"/>
String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.MANAGE_DOCUMENTS};
for(String permission: permissions){
if (ContextCompat.checkSelfPermission(this, permission)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
permission)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(this,
permissions, 0);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
}
Any ideas on how to solve this?
I think the gallery app gives you temporary access to the photo (search FLAG_GRANT_READ_URI_PERMISSION).
As the solution, you can copy the photo into application folder and keep it there.
Your logcat says "requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs".
Have a look in the following link. It should give you an idea or possible solution...
https://stackoverflow.com/a/22178386

Categories

Resources