انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
مشکل در برنامه اندورید

مشکل در برنامه اندورید

#1
سلام خسته نباشید من از یک سرویس استفاده کردم و در داخل یک اکتیویتی فراخوانی کردم موقعی که از داخل اکتیوتی اجرا میشه ولی برنامه بسته بشه دیگه اجرا نمیشه لطفا راهنمایی کنید با تشکر از همه دوستان
کد پی‌اچ‌پی:
package com.androidbegin.sidemenutabstutorial;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.IBinder;
import android.widget.Toast;


public class 
MyServic extends Service {

    private static final 
int NOT_ID 1;
    private 
database         db;

    private static 
int       b      0;


    @
SuppressWarnings("deprecation")
    @
Override
    
public int onStartCommand(Intent intentint flagsint startId) {
        
db = new database(this);
        
db.useable();
        try {
            new 
DoBackgroundTask("http://app.refairan.com/getcount.php").execute();

        }
        catch (
Exception e) {

        }
        
Toast.makeText(this"" "kavos"Toast.LENGTH_LONG).show();

        if (
0) {
            
String ns Context.NOTIFICATION_SERVICE;
            
NotificationManager mNotificationManager = (NotificationManagergetSystemService(ns);

            
int icon R.drawable.ic_action_history;
            
CharSequence tickerText " بیمه سامان ";
            
long when System.currentTimeMillis();

            
int requestID = (int) System.currentTimeMillis();
            
Notification notification = new Notification(icontickerTextwhen);
            
Context context getApplicationContext();
            
Intent notificationIntent = new Intent(thistakhfifat_bime.class);
            
//notificationIntent.putExtra("data1", "My Data 1");
            //  notificationIntent.putExtra("data2", "My Data 2");
            //  notificationIntent.setAction("myString" + requestID);
            
PendingIntent contentIntent PendingIntent.getActivity(thisrequestIDnotificationIntent0);
            
notificationIntent.setData((Uri.parse("mystring" requestID)));
            
notification.setLatestEventInfo(context"Notification Demo"requestID ""contentIntent);
            
notification.flags += Notification.FLAG_ONGOING_EVENT;
            
notification.flags += Notification.FLAG_AUTO_CANCEL;
            
mNotificationManager.notify(NOT_IDnotification);
            
0;

        } else {

            
Toast.makeText(this"kavos" bToast.LENGTH_LONG).show();
        }

        return 
Service.START_FLAG_REDELIVERY;
    }


    @
Override
    
public IBinder onBind(Intent arg0) {
        
// TODO Auto-generated method stub
        
return null;
    }


    private class 
DoBackgroundTask extends AsyncTask<URLIntegerString> {

        private 
String Link "";

        private 
String countS;


        public 
DoBackgroundTask(String link) {
            
Link link;

        }


        @
Override
        
protected String doInBackground(URL... arg0) {
            try {

                
URL mylink = new URL(Link);
                
URLConnection connect mylink.openConnection();

                
BufferedReader reader = new BufferedReader(new InputStreamReader(connect.getInputStream()));
                
StringBuilder sb = new StringBuilder();
                
String line null;
                while ((
line reader.readLine()) != null) {
                    
sb.append(line);
                }

                
countS sb.toString();

            }

            catch (
Exception e) {

            }
            return 
countS;
        }


        @
Override
        
protected void onPostExecute(String result) {
            
super.onPostExecute(result);

            
db.open();
            
int countL db.count_inbox("takhfifat_bime");
            
db.close();
            
Integer.parseInt(result) - countL;

        } 
کد پی‌اچ‌پی:
Intent intent = new Intent(thisMyServic.class);
        
startService(intent); 
کد پی‌اچ‌پی:
}


پاسخ
 سپاس شده توسط شماره مجازی امارات


پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان