Images in RSS (Flash Builder 4.5) - Android Q&A, Help & Troubleshooting

Hello all!
I really need help, because I`m not a programmer, but I make a very simple RSS reader for my website in Flash Builder 4.5, based on this tutorial. Now I have a problem. I need to put images into articles in application (DetailsView). In my RSS feed images in <enclosure> tag. I have no idea how put images in DetailsView and how to get it with enclosure tag.
Please, I really need this and I very greatful for any help!
This is source coude for DetailsView:
Code:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:rssreader="services.rssreader.*"
title="" viewActivate="getDetails()">
<fx:Script>
<![CDATA[
import valueObjects.Item;
[Bindable] private var rtitle:String;
[Bindable] private var rdate:String;
[Bindable] private var rcreator:String;
[Bindable] private var rlink:String;
[Bindable] private var rdesc:String;
private function getDetails():void
{
var p:RegExp = /(")/ig;
var thisItem:Item = data as Item;
rtitle = thisItem.title;
rdate = thisItem.pubDate;
rcreator = thisItem.author;
rlink = thisItem.link;
rdesc = thisItem.description;
rtitle = rtitle.replace(p, "");
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getDataResult"/>
<rssreader:Rssreader id="rssreader"/>
</fx:Declarations>
<s:navigationContent>
<s:Button label="Nazaj" click="navigator.popView()" />
</s:navigationContent>
<s:BorderContainer top="0" bottom="0" left="0" right="0"
backgroundColor="#FFFFFF">
<s:Label left="20" right="20" top="42" height="61"
backgroundColor="#FFFFFF" color="#000000" fontSize="24"
paddingBottom="20" paddingLeft="5" paddingRight="5"
paddingTop="5" text="{rtitle}"/>
<s:Label left="20" right="90" top="14" height="23" backgroundColor="#FEFDFD" color="#666666"
fontSize="18" fontStyle="italic" paddingBottom="5" paddingLeft="5" paddingRight="5"
paddingTop="5" text="{rdate}"/>
<s:BitmapImage y="91" left="20" right="20" height="135" source="image"/>
<s:Label left="20" right="20" top="335" bottom="69" color="#666666"
backgroundColor="#FFFFFF" fontSize="18" paddingBottom="5"
paddingLeft="5" paddingRight="5" paddingTop="5"
text="{rdesc}" maxDisplayedLines="50" />
<s:Button left="50" right="50" bottom="22" label="Preberi celoten Ĩlanek"
click="navigator.pushView(ClanekHTML, data.link)"/>
</s:BorderContainer>
</s:View>
And this is link to my rss feed: http://www.elektro-vozila.si/rssnovice

I found this http://www.telexer.nl/code-snippets/retrieve-images-from-rss-all-of-them/2/ but how to put this code into my code?

Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A

OK, thx for move topic. Anyone in this section have a solution for my problem?

Please, anyone with solution for this problem?

Related

Signature Capture from web page

I am developing a PHP app that runs on an XDA2 PocketPC. It is for use by field engineers to book themselves to jobs whilst on-site, and it will update our internal stock system etc.
The need has arisen for signature capture, whereby a signature area is embedded into a web page and when the client signs the screen, it is transferred safely into a database at our offices.
I have looked at various possibilities but they all seem to rely on ASP/VBSCRIPT.
Has anyone ever come across something that will integrate with my PHP web app?
In a nutshell: Signature region in web page, user signs screen,signature data sent to a SQL database back at base.
Any ideas? :shock:
Hi limepickle
The webbrowser in WM2003 is really quite primitive in comparison to it's desktop counterparts these days. For that reason, i really do not think that you will find a way to do this in the browser.
I write software similar to that which you are talking about using .NET and i've considered using web pages once or twice for simpler apps, but signature capture was always the sticking point which I could never think of a way to acheive...
Sorry to disappoint you :roll:
Pope <><
limepickle said:
I am developing a PHP app that runs on an XDA2 PocketPC. It is for use by field engineers to book themselves to jobs whilst on-site, and it will update our internal stock system etc.
The need has arisen for signature capture, whereby a signature area is embedded into a web page and when the client signs the screen, it is transferred safely into a database at our offices.
I have looked at various possibilities but they all seem to rely on ASP/VBSCRIPT.
Has anyone ever come across something that will integrate with my PHP web app?
In a nutshell: Signature region in web page, user signs screen,signature data sent to a SQL database back at base.
Any ideas? :shock:
Click to expand...
Click to collapse
your gonna get stuck with a php version since the pocket IE isnt that great,
perhaps you can find a flash based signature capture and has flash on the pocket pcs?
this is our solution:
i created a custom application to do this for our company,
its developed using the OpenNet Compact Framework.
its a fullscreen signature app and when the rep is ready to upload the signature they click the send button that transfers it to a ASP.NET web service. this then saves the image as Jpeg to a shared folder and also to SQL for archiving,
check out:
http://www.opennetcf.org/CategoryView.aspx?category=Home
http://www.codeproject.com/netcf/Signature_Capture.asp
this is an example of the code to use in VS.NET with OpenNetCF.
Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Xml;
namespace WGTools
{
/// <summary>
/// Summary description for frmSignatureCapture.
/// </summary>
public class frmSignatureCapture : System.Windows.Forms.Form
{
private OpenNETCF.Windows.Forms.Signature signature1;
private System.Windows.Forms.Button button1;
private OpenNETCF.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private Microsoft.WindowsCE.Forms.InputPanel inputPanel1;
private System.Windows.Forms.ToolBar toolBar1;
private OpenNETCF.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
Guid guid = Rico.Tools.PocketGuid.NewGuid();
public frmSignatureCapture()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmSignatureCapture));
this.groupBox1 = new OpenNETCF.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.signature1 = new OpenNETCF.Windows.Forms.Signature();
this.groupBox2 = new OpenNETCF.Windows.Forms.GroupBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.inputPanel1 = new Microsoft.WindowsCE.Forms.InputPanel();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Location = new System.Drawing.Point(8, 0);
this.groupBox1.Size = new System.Drawing.Size(224, 264);
this.groupBox1.Text = "New Signature";
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 120);
this.button1.Size = new System.Drawing.Size(192, 32);
this.button1.Text = "Create New Signature";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// signature1
//
this.signature1.BackColor = System.Drawing.Color.DimGray;
this.signature1.BackgroundBitmap = ((System.Drawing.Bitmap)(resources.GetObject("signature1.BackgroundBitmap")));
this.signature1.BorderColor = System.Drawing.Color.Black;
this.signature1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.signature1.ForeColor = System.Drawing.Color.White;
this.signature1.Location = new System.Drawing.Point(240, 0);
this.signature1.Size = new System.Drawing.Size(240, 320);
this.signature1.Text = "SignatureControl";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Controls.Add(this.button4);
this.groupBox2.Controls.Add(this.textBox1);
this.groupBox2.Location = new System.Drawing.Point(488, 0);
this.groupBox2.Size = new System.Drawing.Size(224, 264);
this.groupBox2.Text = "Signature Details";
//
// textBox1
//
this.textBox1.AcceptsReturn = true;
this.textBox1.Location = new System.Drawing.Point(8, 24);
this.textBox1.Multiline = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(208, 96);
this.textBox1.Text = "textBox1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(240, 0);
this.button2.Size = new System.Drawing.Size(24, 20);
this.button2.Text = ">";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(240, 248);
this.button3.Size = new System.Drawing.Size(24, 20);
this.button3.Text = "c";
//
// button4
//
this.button4.Location = new System.Drawing.Point(32, 176);
this.button4.Size = new System.Drawing.Size(160, 20);
this.button4.Text = "Upload To HeadOffice";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(32, 208);
this.button5.Size = new System.Drawing.Size(160, 20);
this.button5.Text = "Save To File";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// frmSignatureCapture
//
this.ClientSize = new System.Drawing.Size(1122, 265);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.signature1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.toolBar1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Text = "New Signature";
this.Load += new System.EventHandler(this.frmSignatureCapture_Load);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
this.ControlBox = false;
this.Menu = null;
this.signature1.Location = new System.Drawing.Point(0, 0);
this.button2.Location = new System.Drawing.Point(0, 0);
this.button3.Location = new Point(0,298);
this.Controls.Remove(this.toolBar1);
}
private void button2_Click(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Normal;
this.ControlBox = true;
this.groupBox2.Location = new System.Drawing.Point(8,0);
this.button2.Visible = false;
this.button3.Visible = false;
this.signature1.Visible = false;
this.Controls.Add(this.toolBar1);
this.textBox1.Text = Convert.ToBase64String(this.signature1.GetSignatureEx(),0,this.signature1.GetSignatureEx().Length);
}
private void frmSignatureCapture_Load(object sender, System.EventArgs e)
{
}
private void button4_Click(object sender, System.EventArgs e)
{
//TEST - send the sig to the WS
WSSig.ws1 wssig = new WGTools.WSSig.ws1();
try
{
textBox1.Text = wssig.CaptureSignature_V1("xxxxxx","username","sigID","notes",this.signature1.GetSignatureEx());
}
catch(Exception e3)
{
textBox1.Text = e3.ToString();
}
}
private void button5_Click(object sender, System.EventArgs e)
{
if(Rico.Tools.Stuff.SaveSigToFile("rico","theid","notes",Convert.ToBase64String(this.signature1.GetSignatureEx(),0,this.signature1.GetSignatureEx().Length)))
MessageBox.Show("Saved To File","Saved",MessageBoxButtons.OK,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);
this.textBox1.Text = "saved to file";
}
}
}
Yes, I think you're right, Flash will probably be the way to go, seeing as everyone seems to to be .NET / ASP crazy!!!!
LOL
PS. thanks Pope and djrm, I do appreciate you trying to help, its just that anything to do with .net vb etc, may as well be Urdu.
asp.net web signature capture control
You can try out http://mysignature.brinkster.net for this
Don't Necro old threads for shamelesly plugging your software..

[R&D] Upload files with DropBox

Hi, this is my code, i cant get upload a simple file:
Signgin in to DropBox:
.....private AccessTokenPair tokensDB;
.....private DropboxAPI<AndroidAuthSession> mDBApi;
.....final static private AccessType ACCESS_TYPE = AccessType.DROPBOX;
.....AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
.....AndroidAuthSession sesDropBox = new AndroidAuthSession(appKeys, ACCESS_TYPE);
.....mDBApi = new DropboxAPI<AndroidAuthSession>(sesDropBox);
.....mDBApi.getSession().startAuthentication(this);
When activity resums this code is executed:
.....mDBApi.getSession().finishAuthentication();
.....tokensDB = mDBApi.getSession().getAccessTokenPair();
when the user clicks over a button in same activity next code is executed:
protected void subeArchivos() {
.....// Uploading content.
.....String fileContents = "Hello World, this is only an example!!";
.....ByteArrayInputStream inputStream = new ByteArrayInputStream(fileContents.getBytes());
.....try {
..........mDBApi.putFile("/testing.txt", inputStream, fileContents.length(), null, null);
..........//Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
.....} catch (DropboxUnlinkedException e) {
..........// User has unlinked, ask them to link again here.
..........Log.e("DbExampleLog", "User has unlinked.");
.....} catch (DropboxException e) {
..........toast = Toast.makeText(getApplicationContext(), "C U A: " + e.getMessage(), Toast.LENGTH_SHORT);
..........toast.show();
..........//Log.e("DbExampleLog", "Something went wrong while uploading.");
.....}
}
The code in red throws error. and after the conde in yellow is executed.
My mnifiest permissions are:
.....<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
.....<uses-permission android:name="android.permission.INTERNET"></uses-permission>
.....<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
P.D. All works, exept code in red!!
I hope you can help me!! thx!!
anyone??
I didn't understand anything exc. that you can't upload any file with Dropbox, but I had similar problem. Seems you shouldn't delete the Downloads app, else it bugs DB uploads.
Hope it helps.
thx man, every folder in his place, but maybe something in my code is wrong!!

[Q] RemoteViews - OnClickListener & SetTextViewText

I have been working on a Home Screen widget for the past two days. The widget's `onUpdate()` method calls a service which fetches RSS information (title and image link) using `XmlPullParser`. These are working properly by printing the value in `LogCat`.
I want to set the text in the `TextView (tv1)` of AppWidget and image link as image to the `ImageView (imv1)` and a `TextView (go11)` clickable to open the browser and goto the link. I put the following in `OnStart()` just to test the SetText.
Code:
RemoteViews rv = new RemoteViews(this.getApplicationContext().getPackageName(),R.layout.main);
// Set the text
rv.setTextViewText(R.id.tv1,"WORKED");
Its not working. Second, I tried to set the image by:
Code:
InputStream is = (InputStream) new URL(imglnk).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
rv.setImageViewResource(R.id.imv1, 0);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
rv.setImageViewBitmap(R.id.imv1,bitmap);
Where imglnk is the link to the image. ImageView is not showing the image.
Then I tried to set the OnClick listener to open the browser with google as a test.
Code:
RemoteViews rv1 = new RemoteViews("com.example.axstartup",R.layout.main);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
PendingIntent pi = PendingIntent.getActivity(context, 0, browserIntent,PendingIntent.FLAG_UPDATE_CURRENT);
rv1.setOnClickPendingIntent(R.id.go11, pi);
Even that is not working. Please help me with this.

[Q] What the correct way to read from thumb_image column on messages table (Whatsapp)

Hi all,
I build a software for myself that read from Whatsapp db (that stored on my android device)..
I trying to read from thumb_image column but cannot find the correct way ...
I write this software on c# language... and the code for read its column as follows:
//thumbImage is the value that stored in thumb_image column.
byte[] encodedbytes = System.Text.Encoding.Unicode.GetBytes(thumbImage);
string encoded = System.Convert.ToBase64String(encodedbytes);
byte[] utf8Decoded = System.Text.Encoding.UTF8.GetBytes(encoded);
File.WriteAllBytes("Images\\" + mdeiaName, utf8Decoded);
but it's not working, so i trying to use IronPython as following:
string pythonScript = @"import base64
class DecryptString(object):
def Decrypt(self, str):
return base64.b64encode(str).decode(""utf-8"")";
ScriptEngine engine = Python.CreateEngine();
ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);
ScriptScope scope = engine.CreateScope();
source.Execute(scope);
dynamic DecryptString = scope.GetVariable("DecryptString");
dynamic decryptString = DecryptString();
var result = decryptString.Decrypt(thumbImage);
File.WriteAllText("Images\\" + mdeiaName, result);
but without success...
Can somebody help me?

Samsung Gear Fit SDK Available

Hi all, XDA Developers.
Since the Gear Fit doesn't have an open SDK, i'v been working on for have the Companion UI Profile SDK, and after hours and hours of try and error i got the SDK working.
Since the library only works with Samsung devices it was impossible to test on other devices, but now the library is modified to work with all the devices, independently if it's from Samsung or any other vendor. I'v been developing this with a Nexus 5 with the Samsung Gear Fit Manager installed and it works perfectly.
Here goes attached the SDK with the official docs for developing apps. (The sdk-v1.0.0.jar is not necessary for developing, since all these libraries are now included with the cup-v1.0.0.jar i attached in this zip).
Happy coding!
Can you elaborate on what all we can do with the SDK (develop apps which we can access using APP CONNECT?)?
It'd be great if you can upload the code on Github.
mrdigerati said:
Can you elaborate on what all we can do with the SDK (develop apps which we can access using APP CONNECT?)?
It'd be great if you can upload the code on Github.
Click to expand...
Click to collapse
You can do a lot of things, just read the docs i attached to the zip file. You can make simple applications but it have many power, because you can send images from the phone, etc...
Hi, thanks for your share.
Will this work if I make classic Hello app in Eclipse and then try to import CUP in that app? I mean make Hello CUP in Hello Android app.
pRo_lama said:
Hi, thanks for your share.
Will this work if I make classic Hello app in Eclipse and then try to import CUP in that app? I mean make Hello CUP in Hello Android app.
Click to expand...
Click to collapse
Sure, it worked for me!
Could you please send me your Hello World app from Eclipse, because I'm doing something wrong I guess.
Hi,
Is there emulator to test the application without real device?
Thanks.
drashko said:
Hi,
Is there emulator to test the application without real device?
Thanks.
Click to expand...
Click to collapse
Oh, sorry, i couldn't get that from Samsung
pRo_lama said:
Hi, thanks for your share.
Will this work if I make classic Hello app in Eclipse and then try to import CUP in that app? I mean make Hello CUP in Hello Android app.
Click to expand...
Click to collapse
Since i work only with Android Studio only thing i can make is to send you the proyect with a working code for Android Studio and the imported library.
Hello,
Thanks for providing an the example
I am having issues initializing the cup
java.lang.IllegalStateException: Scup is not initialized
It works perfectly on the S3 but forces closes on Galaxy S4, S5, Note 3
In the documentation it shows:
Code:
Scup scup = new Scup();
try {
// initialize an instance of Scup
scup.initialize(getApplicationContext());
} catch (SsdkUnsupportedException e) {
if (e.getType() == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED) {
// Vendor is not Samsung.
}
}
Any ideas
java.lang.IllegalStateException: Scup is not initialized
CMUK said:
Hello,
Thanks for providing an the example
I am having issues initializing the cup
java.lang.IllegalStateException: Scup is not initialized
It works perfectly on the S3 but forces closes on Galaxy S4, S5, Note 3
In the documentation it shows:
Code:
Scup scup = new Scup();
try {
// initialize an instance of Scup
scup.initialize(getApplicationContext());
} catch (SsdkUnsupportedException e) {
if (e.getType() == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED) {
// Vendor is not Samsung.
}
}
Any ideas
Click to expand...
Click to collapse
I am Also Facing the same issue, if someone knows any workaround to this i'll really appreciate the help.
Edit:
During the App Debugging i found the error before the FC : ScupDialog$1 class is not found :ClassNotFoundException i got on Note 3
Please if its possible to share the Unmodified cup.jar so that i can test it using that
Really Appriciate your effort.
Edit Solution Found :
Add the Following Permission to the AndroidManifast.xml
Code:
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
and It works like a Charm thanks a ton for this SDK now i am constantly working to write apps for my FIT
ksuperman321 said:
I am Also Facing the same issue, if someone knows any workaround to this i'll really appreciate the help.
Edit:
During the App Debugging i found the error before the FC : ScupDialog$1 class is not found :ClassNotFoundException i got on Note 3
Please if its possible to share the Unmodified cup.jar so that i can test it using that
Really Appriciate your effort.
Edit Solution Found :
Add the Following Permission to the AndroidManifast.xml
Code:
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
and It works like a Charm thanks a ton for this SDK now i am constantly working to write apps for my FIT
Click to expand...
Click to collapse
Awesome thanks for finding this it seems to have fixed my app, looking forward to seeing your apps
Does this mean that maybe we'll be able to use its HRM for our own purposes? Say, to find a way to include it in Endomondo?
djurkash said:
Does this mean that maybe we'll be able to use its HRM for our own purposes? Say, to find a way to include it in Endomondo?
Click to expand...
Click to collapse
no the sdk is very limited, you only get a bunch of controls outlined in the documentation pdf
CMUK said:
no the sdk is very limited, you only get a bunch of controls outlined in the documentation pdf
Click to expand...
Click to collapse
Gear fit camera FC after a reboot after a install again it is fine.
I got a refund and when the problem is fixed I will buy it again.
it would be very nice if someone could create an alarm vibrating clock app for non samsung devices, thanks to this sdk.
i really hope it!
cheers!
Hi,
in the cup-v1.0.0.jar there are some funtions missing. especially in the GestureListener class the method onFlick.
It is described in the documentation bit not available in version 1.0.0. Is there anywhere a newer version available?
From the documentation pdf:
@override
public void onFlick(ScupDialog arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
Xamarin Binding
Hey zwegnet fyi i created a Xamarin Binding Android project using your SDK (great work by the way!)
I can't post the link here because a i have to post more then 10 messages before i can add a url.
But if you search on github.com for wsvdmeer you can find.
Thank you
hi, i'm trying to understand how to program the gear fit, but actually i'm stuck on the basics.
i create two activities and one corresponding layout, with this i just get in the gear apps a button that opens an activity on the phone. I want to go further and create an sub app on the gear fit with buttons , how should i modify the code?
can you please share a complete example of a cup app?
Spoiler
Dialog
Code:
package com.dnalexxio.thirdcup;
import java.util.ArrayList;
import com.samsung.android.sdk.cup.ScupButton;
import com.samsung.android.sdk.cup.ScupDialog;
import com.samsung.android.sdk.cup.ScupLabel;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
public class Dialog extends ScupDialog {
private static final int ANIMATION_ALPHA = 0;
private ScupLabel label1;
private int mPageIndex = 0;
private final ArrayList<ScupButton> mButtons = new ArrayList<ScupButton>();
private ScupButton scupButton;
private int x1 = 1;
private int x2 = 1;
private final ScupDialog dialog;
public Dialog(Context context) {
super(context);
dialog = this;
// TODO Auto-generated constructor stub
Log.e("cup1", "aaaa");
}
@Override
protected void onCreate() {
Log.e("cup2", "aaaa");
// TODO Auto-generated method stub
super.onCreate();
ScupLabel scupLabel = new ScupLabel(this);
// Set size for label: width and height
scupLabel.setWidth(ScupLabel.WRAP_CONTENT);
scupLabel.setHeight(ScupLabel.WRAP_CONTENT);
// Set icon for label
// Set text properties for label
scupLabel.setTextSize(6);
scupLabel.setText("cfcc");
scupLabel.setSingleLineModeEnabled(true);
scupLabel.show();
}
public void buttonChange() {
final ScupButton btState = new ScupButton(this);
// Set up icon
btState.setIcon(R.drawable.ic_launcher);
// View of button
btState.setAlignment(ScupButton.ALIGN_VERTICAL_CENTER);
btState.setPadding(5, 0, 5, 0);
// Text parameter
btState.setText("State");
btState.setTextSize(5);
// Set up a click listener
btState.setClickListener(new ScupButton.ClickListener() {
@Override
public void onClick(ScupButton arg0) {
btState.setBackgroundColor(Color.CYAN);
}
});
// Show this button
btState.show();
}
}
Main Activity
Code:
package com.dnalexxio.thirdcup;
import java.io.File;
import com.samsung.android.sdk.SsdkUnsupportedException;
import com.samsung.android.sdk.cup.Scup;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends Activity {
String[] NAMES = {"Hello Cup"};
private Dialog Dialog = null;
// The item of list
private static final int Hello_Cup = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Scup scup = new Scup();
try {
// initialize an instance of Scup
scup.initialize(getApplicationContext());
} catch (SsdkUnsupportedException e) {
if (e.getType() == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED) {
// Vendor is not Samsung.
}
}
int versionCode = scup.getVersionCode();
String versionName = scup.getVersionName();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, NAMES);
ListView mListView = (ListView) findViewById(R.id.demo_lv);
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == Hello_Cup) {
if (Dialog == null) {
Dialog = new Dialog(
getApplicationContext());
} else {
Dialog.finish();
Dialog = null;
}
}
}
});
}
}
}
private Window wind;
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
/******block is needed to raise the application if the lock is*********/
wind = this.getWindow();
wind.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
wind.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
wind.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
/* ^^^^^^^block is needed to raise the application if the lock is*/
}
}
thanks
ale
thx a LOT for the CUP jar you provided. BUT how can I test the app? i mean when i run it in Eclipse with my phone connected, the appears on the phone, and nothing on my gear fit...how it is supposed to appear?

Categories

Resources