- Forum-Beiträge: 745
13.10.2013, 11:53:03 via Website
13.10.2013 11:53:03 via Website
Ich programmiere mit b4a(basic for android) und habe folgenden code in main
2StopService(DownloadService)
3Activity.RemoveAllViews
4Activity.LoadLayout("1rst")
5Dim set As String
6set = File.ReadString(File.DirInternalcache, "str.txt")
7Dim zw As String
8Dim right As Boolean = False
9'set.SubString(120)
10Dim was As String
11For i = 1 To set
12 right = False
13 DownloadService.URL = "(hier ist h+t+p+p+s+.(das forum lässt bei mir keine links zu))dl.dropboxusercontent.com/s/14tvcmhxzwttgrb/"; & i & ".txt?token_hash=AAFj3Ol8_PqSRC25EegKxZYFxX-pniG0jv82B3EDilqYVg&dl=1"
14 DownloadService.Target = File.OpenOutput(File.DirInternalCache, "1.txt", False)
15 StartService(DownloadService)
16 was = File.ReadString(File.DirInternalCache, "1.txt")
17 'zw = was.SubString2(0,120)
18 Do Until right = True
19 If DownloadService.f=True Then
20 right = True
21 End If
22 Loop
23 ListView1.AddSingleLine(was)
24 StopService(DownloadService)
25 Next
2 Dim HC As HttpClient
3 'Activity is expected to set URL
4 Dim URL As String
5 Dim Target As OutputStream
6 Dim JobStatus As Int
7 Dim STATUS_NONE, STATUS_WORKING, STATUS_DONE As Int
8 STATUS_NONE = 0
9 STATUS_WORKING = 1
10 STATUS_DONE = 2
11 Dim DoneSuccessfully As Boolean
12 Dim Notification1 As Notification
13 Dim f As Boolean
14End Sub
15Sub Service_Create
16 HC.Initialize("HC")
17 Notification1.Initialize
18 Notification1.Icon = "icon" 'use the application icon file for the notification
19 Notification1.Vibrate = False
20End Sub
21
22Sub Service_Start
23 'URL and Target should be set by the calling module
24 Dim request As HttpRequest
25 request.InitializeGet(URL)
26 HC.Execute(request, 1)
27 JobStatus = STATUS_WORKING
28 Notification1.SetInfo("Starten des AppStores", "Abrufen der Apps...", Main)
29 Notification1.Vibrate = True
30 Notification1.Sound=False
31 'Make sure that the process is not killed during the download
32 'This is important if the download is expected to be long.
33 'This will also show the status bar notification
34 Service.StartForeground(1, Notification1)
35End Sub
36
37Sub HC_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
38 ToastMessageShow("Error beim Laden der Apps- Grund: " & Reason, True)
39 Main.grund= Reason
40 CallSub(Main,"Error")
41
42 DoneSuccessfully = False
43 'Finish
44End Sub
45
46Sub HC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
47 'Asynchronously download the stream
48 Response.GetAsynchronously("Response", Target, True, TaskId)
49End Sub
50
51Sub Response_StreamFinish (Success As Boolean, TaskId As Int)
52 If Success = False Then
53 ToastMessageShow("Error beim Laden der Apps- Grund: " & LastException.Message, True)
54
55 Else
56 Finish
57 End If
58 DoneSuccessfully = Success
59
60End Sub
61
62Sub Finish
63 Log("Service finished downloading")
64 JobStatus = STATUS_DONE
65 'Notify the activity that the download has finished.
66 'It will do nothing if the activity is currently paused.
67 f = True
68 Service.StopForeground(1) 'Return the service to the "background" (also removes the ongoing notification)
69 CallSub(Main, "fertig")
70
71End Sub
72
73Sub Service_Destroy
74f =False
75End Sub
Meine absicht ist es einen kleinen appstore zu machen.
Mfg und danke für die hilfe
-unten sind noch weitere fragen!
— geändert am 13.10.2013, 17:24:53
Posts vor dem 22.12.2014 sind von dem Vorgänger dieses Accounts
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.