2013-01-16 6 views
1

내가 응용 프로그램을 쓰고 있어요 ..페이스 북 친구에 대한 알림/알림을받을 방법 다가오는 생일 내 모든 페이스 북 친구</em>의 <em>가져 오기 목록입니다있는

그러나 지금 나는 내 애플 리케이션에 하나 더 많은 기능을 추가 할

public class FriendListAdapter extends BaseAdapter implements 
     SectionIndexer { 
    private LayoutInflater mInflater; 

    private GetProfilePictures picturesGatherer = null; 
    FriendsList friendsList; 
    private String[] sections; 

    Hashtable<Integer, FriendItem> listofshit = null; 

    public FriendListAdapter(FriendsList friendsList) { 

     this.friendsList = friendsList; 
     sections = new String[getCount()]; 
     listofshit = new Hashtable<Integer, FriendItem>(); 


     for (int i = 0; i < getCount(); i++) { 
      try { 

       sections[i] = jsonArray.getJSONObject(i).getString("name") 
         .substring(0); 
       sections[i] = jsonArray.getJSONObject(i) 
         .getString("birthday").substring(1); 


      } catch (JSONException e) { 
       sections[i] = ""; 

      } 
     } 
     if (picturesGatherer == null) { 
      picturesGatherer = new GetProfilePictures(); 
     } 
     picturesGatherer.setAdapterForListener(this); 
     mInflater = LayoutInflater.from(friendsList.getBaseContext()); 
    } 

    public int getCount() { 

     if (jsonArray == null) 
      return 0; 
     return jsonArray.length(); 
    } 

    public Object getItem(int position) { 

     return listofshit.get(position); 
    } 

    public long getItemId(int position) { 

     return position; 
    } 

    public View getView(int position, View convertView, ViewGroup parent) { 


     JSONObject jsonObject = null; 
     try { 
      jsonObject = jsonArray.getJSONObject(position); 
     } catch (JSONException e) { 

     } 

     FriendItem friendItem; 

     if (convertView == null) { 
      convertView = mInflater.inflate(R.layout.single_friend, null); 
      friendItem = new FriendItem(); 

      convertView.setTag(friendItem); 
     } else { 
      friendItem = (FriendItem) convertView.getTag(); 
     } 

     friendItem.friendPicture = (ImageView) convertView 
       .findViewById(R.id.picture_square); 
     friendItem.friendName = (TextView) convertView 
       .findViewById(R.id.name); 
     friendItem.friendDob = (TextView) convertView 
       .findViewById(R.id.dob); 
     friendItem.friendLayout = (RelativeLayout) convertView 
       .findViewById(R.id.friend_item); 

     try { 
      String uid = jsonObject.getString("uid"); 
      String url = jsonObject.getString("pic_square"); 
      friendItem.friendPicture.setImageBitmap(picturesGatherer 
        .getPicture(uid, url)); 
     } catch (JSONException e) { 

      friendItem.friendName.setText(""); 
      friendItem.friendDob.setText(""); 
     } 

     try { 
      friendItem.friendName.setText(jsonObject.getString("name")); 
      friendItem.friendDob.setText(jsonObject.getString("birthday")); 
     } catch (JSONException e) { 

      friendItem.friendName.setText(""); 
      friendItem.friendDob.setText(""); 
     } 

     listofshit.put(position, friendItem); 
     return convertView; 
    } 

    public int getPositionForSection(int position) { 
     return position; 
    } 

    public int getSectionForPosition(int position) { 
     return position; 
    } 

    public Object[] getSections() { 
     return sections; 
    } 
} 
+0

앱 내부 작업이나 오프라인 기능으로 원하십니까? –

+0

@Sahil 나는 사용자가 앱을 사용하고 있지 않더라도 알림을 받길 원합니다 ... – Liza

답변

0

당신은 CRON을 사용하고 012 수 는 통지를 얻을 수/곧 친구에 대한 알림 내가 모든 친구의 목록을 얻기 위해 코드 아래 사용하고

을 생일 페이 스북 (Facebook)의.

  1. 먼저 당신은 당신의 데이터베이스에 사용자의 토큰 ID확장 액세스을 저장해야합니다.
  2. 그런 다음, 스케줄러를 실행하고 사용자의 토큰
  3. 알림 API를 사용하여 사용자에게 통지를 보내 사용하여 각 사용자의 친구의 생일을 가져 오기 (단지 필요 APP 액세스 토큰 - 당신이 here에서 얻을 수있는)