please help ,
i'm trying to make an app which i need to add event to the phone calendar by development of-course, how can i start, any sample code, i'm new to android development
moamenam said:
please help ,
i'm trying to make an app which i need to add event to the phone calendar by development of-course, how can i start, any sample code, i'm new to android development
Click to expand...
Click to collapse
if there is any document i can read please support me with it, i really need to make my first android app
code snipped
Code:
private void SetCalenderEntry(String calID, long date, String subject, String body, String location)
{
ContentValues event = new ContentValues();
event.put("calendar_id", calID);
event.put("title", subject);
event.put("description", body);
event.put("eventLocation", location);
long startTime = date;
event.put("dtstart", startTime);
event.put("dtend", startTime);
Uri eventsUri = Uri.parse("content://calendar/events");
getContentResolver().insert(eventsUri, event);
}
Related
Hi,
I am reading a book on Android development. In one of the source code examples the author uses the construct:
String tt = **;
I assume he is initializing his new string to empty, but I have never seen this before and just want to be sure. There is probably a more detailed meaning.
Google search doesn't find anything like this. Can someone confirm what this means?
Thanks for any info or pointers to the definition.
Barry.
Uh, that's an error.
// Initialize String, 2 ways
String tt = null; // I always use this
String tt = ""; // empty string can be unpredictable
So, I wrote this block of code:
Code:
ContentValues values = new ContentValues();
values.put(BookmarkColumns.BOOKMARK, "1");
values.put(BookmarkColumns.CREATED, "1311170108");
values.put(BookmarkColumns.DATE, "1311170708");
values.put(BookmarkColumns.FAVICON, "favicon");
values.put(BookmarkColumns.TITLE, "XDA");
values.put(BookmarkColumns.URL, "http://forum.xda-developers.com");
values.put(BookmarkColumns.VISITS, "1");
getContentResolver().insert(Browser.BOOKMARKS_URI, values);
When executed, I get no errors. Looking in the browser bookmarks section, the book mark is not there. If i click the Most Visited tab, this shows up and also has the yellow bookmark star next to it, indicating that it is a bookmark. If i click the star to unbook mark it, and click it again, then view the Bookmarks tab, it shows up.
If I use another piece of code to print out all the bookmarks found after I add it, mine shows up
Even with rebooting, they are not showing.
So I ask, why is it that they are not showing up in the bookmarks page of the browser?
I have tried everything and looked around everywhere, and nothing
Thanks!
there is no sanctioned way of adding a bookmark without user input. the normal way would be a call to android.provider.Browser.saveBookmark()
Code:
public static final void saveBookmark(Context c, String title, String url) {
Intent i = new Intent(Intent.ACTION_INSERT, Browser.BOOKMARKS_URI);
i.putExtra("title", title);
i.putExtra("url", url);
c.startActivity(i);
}
other than that dealing with the DB directly would be the only way to add one. try to follow that startActivity to the dialog and see if there is an intent sent to the Browser telling it the DB was updated
killersnowman said:
there is no sanctioned way of adding a bookmark without user input. the normal way would be a call to android.provider.Browser.saveBookmark()
Code:
public static final void saveBookmark(Context c, String title, String url) {
Intent i = new Intent(Intent.ACTION_INSERT, Browser.BOOKMARKS_URI);
i.putExtra("title", title);
i.putExtra("url", url);
c.startActivity(i);
}
other than that dealing with the DB directly would be the only way to add one. try to follow that startActivity to the dialog and see if there is an intent sent to the Browser telling it the DB was updated
Click to expand...
Click to collapse
But, even with restarting the device the book marks are not there. Surely the browser updates the database at that point.
But it also dosnt make sense because if the page was shown in the history, it has the bookmarked indicator next to it
I must do all of this in a fully transparent way. Showing that popup for each one will not do :/
there are a few other columns that are interesting. 'user_entered' which can be '0' or '1'
But I think your best bet is to find the dialog that saveBookmark() calls and analyze its src
Here it is addBookmark()
http://www.java2s.com/Open-Source/A...rowser/com/android/browser/Bookmarks.java.htm
It appears to be static. Why not just call this method?
static void addBookmark(Context context, ContentResolver cr, String url, String name, Bitmap thumbnail, boolean retainIcon)
------nvm i think its package restricted
From something awesome
Last day I opened my Strings.xml file with Notepad and added all my needed texts to it. Today I opened eclipse and wrote this code :
TextView title1 = (TextView) findViewById (R.string.myAddedTextName);
But the problem is that eclipse cannot find that. I restarted it but it didn't work again. I checked the strings.xml file by eclipse. Everything was corect but the R.String (gen) hasn't saved them. Now I can't accses the texts. Is there anyway I can access them?
Thanks in advance.
You can clean the project. That way it will build again. Just select Project > Clean... and then select your project.
I may be wrong but I don't think you can do this: TextView title1 = (TextView) findViewById (R.string.myAddedTextName);
TextView is a widget object. You are telling eclipse to find a TextView (by id) but are telling it to look for a stored string.
zalez said:
I may be wrong but I don't think you can do this: TextView title1 = (TextView) findViewById (R.string.myAddedTextName);
TextView is a widget object. You are telling eclipse to find a TextView (by id) but are telling it to look for a stored string.
Click to expand...
Click to collapse
That is right. Ids are integer values. I did not see that. :laugh:
Change it to
Code:
TextView title1 = (TextView) findViewById (R.id.myAddedId);
You set the id that way:
Code:
<Button ...
android:id="@+id/myAddedId"
... />
This is what I was thinking:
If title1 is indeed a TextView in your layout you would do this:
Code:
TextView title1 = (TextView) findViewById(R.id.myTextView);
title1.setText(R.string.myAddedTextName);
Thank you.
The strings are now OK.
Also the famous TextView = String which I wrote at the first post has no problem in eclipse.
torpedo mohammadi said:
Thank you.
The strings are now OK.
Also the famous TextView = String which I wrote at the first post has no problem in eclipse.
Click to expand...
Click to collapse
This is because R.id......
And R.string........ Point to int data type so compiler won't mind
Not to mention it will crash at runtime
Sent from my GT-S5302 using Tapatalk 2
So, suppose I have written a text in the strings.xml like :
<String name ="text">Hi there.</string>
Using which code can retreive the "Hi there."? I have something in my mind:
String s = getString(R.string.text);
Or
String s = getResources().getString(R.string.text);
Which one can give me the "Hi there."?
The first one. Not sure about the second one, but just use the first
Both of them will do the same job
Sent from my GT-S5302 using Tapatalk 2
Guys. Help me. I'm learning to ''Respond to the Send Button'' but I don't know what to do. I follow this step but I still can't understand.
http://developer.android.com/training/basics/firstapp/starting-activity.html
If you guys can help me, I'm really grateful.
Merivex95 said:
Guys. Help me. I'm learning to ''Respond to the Send Button'' but I don't know what to do. I follow this step but I still can't understand.
http://developer.android.com/trainin...-activity.html
If you guys can help me, I'm really grateful.
Click to expand...
Click to collapse
That link didn't work, but if you Google 'android java button onclick listener' that will get you started with plenty of helpful links.
When the button is clicked, you then need to check the content of the Edit Text field - Something like this:
Code:
public void onClick(final View v) {
final String commandText = inputText.getText().toString();
if (commandText != null && commandText.length() > 0) {
Where inputText is the Edit Text field you've assigned in your OnCreate method.
Getting started involves a lot of head scratching, but don't give up! There's so much Open Source code out there, that the penny will drop soon.
brandall said:
That link didn't work, but if you Google 'android java button onclick listener' that will get you started with plenty of helpful links.
When the button is clicked, you then need to check the content of the Edit Text field - Something like this:
Code:
public void onClick(final View v) {
final String commandText = inputText.getText().toString();
if (commandText != null && commandText.length() > 0) {
Where inputText is the Edit Text field you've assigned in your OnCreate method.
Getting started involves a lot of head scratching, but don't give up! There's so much Open Source code out there, that the penny will drop soon.
Click to expand...
Click to collapse
OMG !! this is the link : http://developer.android.com/training/basics/firstapp/starting-activity.html
I don't know how to compile the code properly. hummmm ... maybe you can help me by correcting my code ?
Paste code (variables, functions, etc) inside your MainActivity class and don't write 3 dots, it's just a replacement for skipped parts
Mikanoshi said:
Paste code (variables, functions, etc) inside your MainActivity class and don't write 3 dots, it's just a replacement for skipped parts
Click to expand...
Click to collapse
Ohhh yeahhh :cyclops: .. how can I be so stupid
btw ,, where should I put this code ?
code:
Code:
@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
Code:
Merivex95 said:
btw ,, where should I put this code ?
Click to expand...
Click to collapse
Replace existing onCreate function with it.
Mikanoshi said:
Replace existing onCreate function with it.
Click to expand...
Click to collapse
But I get an error after doing that ..
Merivex95 said:
But I get an error after doing that ..
Click to expand...
Click to collapse
You need to import TextView and Intent first. Just hover over the names and select import from the menu you will see.
Seriously, my advice would be to learn and understand Java first. It doesn't make sense to learn Android if you don't know Java (and it won't work).
nikwen said:
You need to import TextView and Intent first. Just hover over the names and select import from the menu you will see.
Seriously, my advice would be to learn and understand Java first. It doesn't make sense to learn Android if you don't know Java (and it won't work).
Click to expand...
Click to collapse
Thanks for the advice
nikwen said:
It doesn't make sense to learn Android if you don't know Java (and it won't work).
Click to expand...
Click to collapse
Unless you know any other similar languages. Java was the easiest lang to learn for me, after years of writing on Object Pascal/Object C/C++/JavaScript/PHP. The most troublesome part of coding for Android is creating an UI, especially cross-version compatible :laugh:
Hello everyone ^_^
Ive been making zooper themes for some time, as well as Themer themes. What i would love to do now is to create an app that can install a zip file to a specific folder on the storage. I wish to make a Material themed app for installing the zip, that can show scereenshots or other shots which i use to display my themes. Also, I wish to include a link for the wallpaper for that specific theme. Ive scoured the internet a bit for this type of thing, and so far, ive been unable to find anything that would suit my requirement.
help would be appreciated a lot
PS, i havent done app developing or coding in a few years so you could say that im kinda noob to this now so guidance from scratch would be very helpful ^_^
You can use below code to create a zip and place it wherever you want.
Code:
private static void zipFolder(String inputFolderPath, String outZipPath) {
try {
FileOutputStream fos = new FileOutputStream(outZipPath);
ZipOutputStream zos = new ZipOutputStream(fos); File srcFile = new File(inputFolderPath);
File[] files = srcFile.listFiles();
Log.d("", "Zip directory: " + srcFile.getName());
for (int i = 0; i < files.length; i++) {
Log.d("", "Adding file: " + files[i].getName());
byte[] buffer = new byte[1024];
FileInputStream fis = new FileInputStream(files[i]); zos.putNextEntry(new ZipEntry(files[i].getName()));
int length;
while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length); }
zos.closeEntry();
fis.close();
}
zos.close();
}
catch (IOException ioe) { Log.e("", ioe.getMessage());
}
}
And for the second one.
You can simple use intent to open your link in browser.
Intent n = new Intent(Intent.ACTION_VIEW , Uri.parse("link to your wallpaper"));
Sent from my A0001 using Tapatalk 2
Android Application Development Request
I am in need of some help I have a great idea for a new app that may change the face of advanced research. This will allow for the user to search all day and all night. While they are handling everyday life issues and events with family and what not. Yet still, allowing them to locate what they are looking for. Also will allow people with artifacts in there home. That the user may think is not worth anything yet it may be a goldmine. So instead of the user having to do research trying to locate these specific artifacts to see if they are worth money. This app will allow them to do advanced research all day with a touch of a button my idea is revolutionary when it comes to the advanced research that needs to be done. Please, I am looking for somebody to help me develop this app and bring it to life. So that I may present this idea to google for a possible sale. Thank you for your consideration ahead of time on helping me with this application.