android-activity

Why I can't read a read only file?

故事扮演 提交于 2019-12-31 05:29:16
问题 I have this method supposed to read a file: /* Read file's content */ private ArrayList<String> readFromFile() { File file = new File("jokesBody1.bjk"); ArrayList<String> list = new ArrayList<String>(); try { file.createNewFile(); ObjectInputStream ois = new ObjectInputStream( new FileInputStream( file ) ); try { list = (ArrayList)ois.readObject(); } catch (ClassNotFoundException e) { e.printStackTrace(); } ois.close(); } catch (IOException e) { Log.e("log activity", "Can not read file: " + e

How to achieve multiple datepicker functionality with two buttons and save those dates that are picked?

霸气de小男生 提交于 2019-12-31 04:45:33
问题 I want to create an activity in which I want to have two button and multiple label. a user can click on buttons to select dates from and to. while those selected dates can be shown in label so that user might know which dates already picked by user. Can anybody guide me how can I do this. using multiple date-picker functionality with only two date pickers on two buttons. how can I save those dates. so whenever user leave this activity and visit again he might know. 回答1: I have created

Flash video keeps playing even after back button is pressed android

放肆的年华 提交于 2019-12-31 04:37:10
问题 So I've created a WebView and set the content to an html string like so (This gets called when a user presses a ListView Item): String html = "<html>" + "<body style=\"padding:0px;margin:0px;border:0px none;\">" + "<embed type=\"application/x-shockwave-flash\"" + " id=\"stratos_embed\"" + " width=\"100%25\" height=\"100%25"\"" + //%25 = % (escaped) " src=\"myVideoSource.swf\"" + " pluginspage=\"http://www.macromedia.com/go/getflashplayer\"" + " allowfullscreen=\"true\" allowscriptaccess=\

How to send data from service to activity?

拥有回忆 提交于 2019-12-31 04:07:28
问题 I'm beginner in Android development. I try to create kind of MusicPlayer, which uses Service for playing music. When I click buttons in MainActivity, I call startService with Intent, which includes signal for action, such as play, pause, stop, etc... But I want to send data back from service to activity. For example, when current track has stopped and begin to play the next one, MainActivity got to receive track name and author name. Or when last track in the playlist is stopped, button

How to send SMS message reply to email address?

蓝咒 提交于 2019-12-31 04:05:05
问题 I have a simple SMS Activity that replies to a SMS message that was sent to the phone. Some SMS messages have the originating address as an email address. How do you compose a reply SMS message that can successfully be sent back? 回答1: So the solution to this seemed to be this: Each cell carrier has a specific SMS number that you can send a text message to in a certain format. This is called a "SMS Gateway". (Similarly, there are gateways to send SMS messages from Email addresses.) Example: AT

setContentView in fragment

依然范特西╮ 提交于 2019-12-31 03:39:06
问题 I'm trying to convert a Activity to fragment. The error mark on setContentView. here is my code public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_googlev2); Init(); addMarkersToMap(); yStart = 21.102918; yEnd = 20.960798; xStart = 105.772762; xEnd = 105.900650; xNow = xStart; yNow = yStart; adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line); textView = (AutoCompleteTextView) getView

Android: Detect General Use by User

♀尐吖头ヾ 提交于 2019-12-31 03:16:32
问题 I am working on an application that monitors phone use (specifically, what time its being used). Presently, I log times of phone calls, SMSs, MMSs, Screen turning on, screen turning off, and keygaurd unlocking. Now I want to determine when the user does any interaction other than whats listed above. Like: 1) Application use (Detect when an application is launched by the user and/or when it is actively being used by the user) For this I have been playing with the Activity Manager but there

On Button Click how to increment counter and show in textview

被刻印的时光 ゝ 提交于 2019-12-31 03:15:09
问题 I am working on a shopping cart assignment for that I have created a custom ListView that contains the Picture, Price and Add to Cart button in each row. I also have a textview at the top which increments everytime the user presses the Add to cart. The Button in every row is perfectly working fine but I don't know how to increment the counter and set it to the textview as whenever I do this under onClick event I get runtime error. I am sharing with you the code. package uet.cs08.bll; import

Update the UI with dynamic text

拥有回忆 提交于 2019-12-31 03:10:31
问题 I wish to update the text on the screen every 5 second, I have created a timer to do so. However after the first update it never updates the box again. I am assuming I need to refresh the view or something but I am now sure how, any Ideas? public class HomeActivity extends Activity implements OnClickListener { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textTitle = (TextView) findViewById(R.id.textTitle); textArtist =

Update the UI with dynamic text

送分小仙女□ 提交于 2019-12-31 03:10:26
问题 I wish to update the text on the screen every 5 second, I have created a timer to do so. However after the first update it never updates the box again. I am assuming I need to refresh the view or something but I am now sure how, any Ideas? public class HomeActivity extends Activity implements OnClickListener { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textTitle = (TextView) findViewById(R.id.textTitle); textArtist =